C#创建文件夹

//获取当前文件夹路径
string currPath = Application.StartupPath;
//检查是否存在文件夹
string subPath = currPath + "/pic/";
if (false == System.IO.Directory.Exists(subPath)){
     //创建pic文件夹
     System.IO.Directory.CreateDirectory(subPath);
}
//确认创建文件夹是否成功,如果不成功,则直接在当前目录保存
TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
string picName=Convert.ToInt64(ts.TotalSeconds).ToString()+".jpg";
string picPath;
if (false == System.IO.Directory.Exists(subPath)){
    picPath = currPath + "/" + picName;
}else{
    picPath = subPath + picName;
}

 

posted @ 2018-07-30 11:19  QianTM  阅读(46637)  评论(4编辑  收藏  举报