Quantcast
Channel: How do I create a file AND any folders, if the folders don't exist? - Stack Overflow
Browsing all 10 articles
Browse latest View live

Answer by Mehdi Dehghani for How do I create a file AND any folders, if the...

Following code will create directories (if not exists) & then copy files.// using System.IO;// for ex. if you want to copy files from D:\A\ to D:\B\foreach (var f in Directory.GetFiles(@"D:\A\",...

View Article



Answer by hultqvist for How do I create a file AND any folders, if the...

To summarize what has been commented in other answers://path = @"C:\Temp\Bar\Foo\Test.txt";Directory.CreateDirectory(Path.GetDirectoryName(path));Directory.CreateDirectory will create the directories...

View Article

Answer by PRR for How do I create a file AND any folders, if the folders...

Assuming that your assembly/exe has FileIO permission is itself, well is not right. Your application may not run with admin rights. Its important to consider Code Access Security and...

View Article

Answer by Markive for How do I create a file AND any folders, if the folders...

You want Directory.CreateDirectory()Here is a class I use (converted to C#) that if you pass it a source directory and a destination it will copy all of the files and sub-folders of that directory to...

View Article

Answer by Christopher B. Adkins for How do I create a file AND any folders,...

DirectoryInfo di = Directory.CreateDirectory(path);Console.WriteLine("The directory was created successfully at {0}.", Directory.GetCreationTime(path));See this MSDN page.

View Article


Answer by Arseny for How do I create a file AND any folders, if the folders...

. given a path, how can we recursively create all the folders necessary to create the file .. for that pathCreates all directories and subdirectories as specified by path....

View Article

Answer by Nick for How do I create a file AND any folders, if the folders...

You should use Directory.CreateDirectory.http://msdn.microsoft.com/en-us/library/54a0at6s.aspx

View Article

Answer by Grzenio for How do I create a file AND any folders, if the folders...

Use Directory.CreateDirectory before you create the file. It creates the folder recursively for you.

View Article


Answer by Oded for How do I create a file AND any folders, if the folders...

You will need to check both parts of the path (directory and filename) and create each if it does not exist.Use File.Exists and Directory.Exists to find out whether they exist....

View Article


How do I create a file AND any folders, if the folders don't exist?

Imagine I wish to create (or overwrite) the following file :- C:\Temp\Bar\Foo\Test.txtUsing the File.Create(..) method, this can do it.BUT, if I don't have either one of the following folders (from...

View Article
Browsing all 10 articles
Browse latest View live




Latest Images