Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
455 views
in Technique[技术] by (71.8m points)

asp.net - Check if a folder exist in a directory and create them using C#

How can I check if directory C:/ contains a folder named MP_Upload, and if it does not exist, create the folder automatically?

I am using Visual Studio 2005 C#.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This should help:

using System.IO;
...

string path = @"C:MP_Upload";
if(!Directory.Exists(path))
{
    Directory.CreateDirectory(path);
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...