C# create file in current directory code example
Example 1: file.create folder c#
Using System.IO;
//gets the directory where the program is launched from and adds the foldername
string path = Path.Combine(Environment.CurrentDirectory, "foldername");
//Creates a directory(folder) if it doesen't exist
Directory.CreateDirectory(path);
Example 2: create a file in the directory of the exe and write to it c#
string GuarnteedWritePath = System.Environment.
GetFolderPath(
Environment.SpecialFolder.CommonApplicationData
);
string FilePath = Path.Combine(GuarnteedWritePath, "LogFile.txt");