//獲取當前文件夾路徑
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;
}
