Check if a folder exist in a directory and create them using C#

前端 未结 7 849
青春惊慌失措
青春惊慌失措 2020-12-01 02:44

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 V

7条回答
  •  北海茫月
    2020-12-01 03:07

    This should help:

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

提交回复
热议问题