C#創建文件夾


//獲取當前文件夾路徑
            string currPath = Application.StartupPath;

//檢查是否存在文件夾
            string subPath = currPath + "/pic/";
            if (false == System.IO.Directory.Exists(subPath))
            {
 //創建pic文件夾
                System.IO.Directory.CreateDirectory(subPath);
            }
//確認創建文件夾是否成功,如果不成功,則直接在當前目錄保存
            System.DateTime currentTime = new System.DateTime();
            currentTime = System.DateTime.Now;
            string picName;
            picName =
                currentTime.Year.ToString() +
                currentTime.Month.ToString() +
                currentTime.Day.ToString() +
                currentTime.Hour.ToString() +
                currentTime.Minute.ToString() +
                currentTime.Second.ToString() +
                currentTime.Millisecond.ToString() +
                ".jpg";

            string picPath;
            if (false == System.IO.Directory.Exists(subPath))
            {
                picPath = currPath + "/" + picName;
            }
            else
            {
                picPath = subPath + picName;
            }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM