Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# create empty file if not exists

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.");
        }
 
PREVIOUS NEXT
Tagged: #create #empty #file #exists
ADD COMMENT
Topic
Name
6+1 =