📌  相关文章
📜  c# 如果文件不存在则创建它 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:08.549000             🧑  作者: Mango

代码示例1
string temp = AppDomain.CurrentDomain.BaseDirectory;
string sPath = Path.Combine(temp, "file.txt");

bool fileExist = File.Exists(sPath);
        if (fileExist) {
            Console.WriteLine("File exists.");
        }
        else {
          using (File.Create(sPath)) ;
            Console.WriteLine("File does not exist.");
        }