using System.IO;

Does directory exist?

(Note paths can include a filename if you wish)


	if (!Directory.Exists(Path.GetDirectoryName(MyFileName)))
		Directory.CreateDirectory(Path.GetDirectoryName(MyFileName));
	//or
	String path;
	path = "C:\\Atest\\";				//		'\\'='\'
	if (!Directory.Exists(path))
	//or
	if (!Directory.Exists("C:\\Atest\\"))	//		'\\'='\'

Create Directory

(Note paths can include a filename if you wish)


	Directory.CreateDirectory(Path.GetDirectoryName(MyFileName));
	//or
	String path;
	path = "C:\\Atest\\";				//		'\\'='\'
	Directory.CreateDirectory(path);
	//or
	Directory.CreateDirectory("C:\\Atest\\");	//		'\\'='\'

Get Directory From File Path


	sTemp = Path.GetDirectoryName(MyFilename)

 

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *