create file and directory c# code example
Example 1: c# making a folder
string path1 = @"C:\temp\";
string path2 = Path.Combine(path1, "temp1");
Directory.CreateDirectory(path2);
Example 2: file.create folder c#
Using System.IO;
string path = Path.Combine(Environment.CurrentDirectory, "foldername");
Directory.CreateDirectory(path);
Example 3: 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");