What\'s the simplest/canonical way to create an empty file in C#/.NET?
The simplest way I could find so far is:
System.IO.File.WriteAllLines(filename
Path.GetTempFileName() will create a uniquly named empty file and return the path to it.
If you want to control the path but get a random file name you can use GetRandomFileName to just return a file name string and use it with Create
For example:
string fileName=Path.GetRandomFileName();
File.Create("custom\\path\\" + fileName);