+ 1
how to create a file in a specific path?
If I want to create a file on C: drive..or any other place in pc..how can I give that path to my c# code?
2 Réponses
+ 3
https://www.dotnetperls.com/filestream
using sytem.io
using (FileStream fileStream =
File.Create(@"C:\programs\example1.txt"))
using (StreamWriter writer = new StreamWriter(fileStream))
{
writer.WriteLine("Example 1 written");
}
Notice that you are not allowed to create file everywhere. So make sure you have rights to write in the location you want to write.