I wanna create a new folder named log
and inside that folder i want to create
a textfile named log.txt
and this is the path i want to create D:\New Folder
i have tried this to create a new folder named log
string FilePathSave = Folder.ToString() + System.IO.Directory.CreateDirectory(@"D:\New Folder\Log");
And i have created a text file using this
string FilePathSave = Folder.ToString() +"log.txt";
File.WriteAllText(FilePathSave, TextBox1.Text);
But i cant create like D:\New Folder\Log\log.txt
...any suggestion??
Tip: You can also right-click any folder in the Folder Pane and click New Folder. Type your folder name in the Name text box. In the Folder Contains drop-down menu, click Mail and Post Items. In the Select where to place the folder box, click the folder under which you want to place your new subfolder.
Procedure. Click Actions, Create, Folder. In the Folder name box, type a name for the new folder. Click Next.
Windows uses folders to help you organize files. You can put files inside a folder, just like you would put documents inside a real folder.
Urm, something like this?
var dir = @"D:\New folder\log"; // folder location
if(!Directory.Exists(dir)) // if it doesn't exist, create
Directory.CreateDirectory(dir);
// use Path.Combine to combine 2 strings to a path
File.WriteAllText(Path.Combine(dir, "log.txt"), "blah blah, text");
string dir = @"D:\New Folder\Log";
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}
File.WriteAllText(Path.Combine(dir, "log.txt"), TextBox1.Text);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With