簡體   English   中英

我刪除 zip 文件夾時出現錯誤,因為目錄名稱無效

[英]while im deleting zip folder getting An Error as The directory name is invalid

我有一個像

  String path = HttpContext.Current.Server.MapPath("~/Images");

這個文件夾我正在轉換成 Zip

 string zipPath = path + ".zip";
            ZipFile.CreateFromDirectory(path, zipPath, CompressionLevel.Fastest, true);

我再次刪除這個 flder 作為

 System.IO.DirectoryInfo dir = new DirectoryInfo(@"D:\EMS BackUP\Mohd_Ems\EMSIMPORTANTSOURCECODE\EMS_SOURCE_CODE\EMS\EMS\Images.zip");
            dir.Attributes = dir.Attributes & ~FileAttributes.ReadOnly;
            dir.Delete(true);

在 dir.Delete(true) 我收到一個錯誤,因為目錄名稱無效。

請嘗試使用System.IO.Directory.Delete(path,true)遞歸刪除所有文件

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM