Answers for "how to create file if not exists c#"

C#
0

c# if file doesn't exist create it

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.");
        }
Posted by: Guest on September-18-2021

Code answers related to "how to create file if not exists c#"

C# Answers by Framework

Browse Popular Code Answers by Language