尝试在 Azure 本地存储下压缩文件时显示错误。我正在尝试将.ps1
文件压缩到<filename>.ps1.zip
并且出现错误
目录名称无效。
代码:
string scriptPath = Path.Combine(fileDirectoryPath, fileName);
string destFilePath = string.Empty;
List<string> zipFolderDetails = new List<string>();
if (!File.Exists(scriptPath))
{
throw new Exception(string.Format("ZipFile : No file exists in the source path {0}", fileName));
}
string newDirectoryPath = Path.Combine(Utilities.GetLocalDirectoryScriptPath(), Guid.NewGuid().ToString());
zipFolderDetails.Add(newDirectoryPath);
Directory.CreateDirectory(newDirectoryPath);
destFilePath = newDirectoryPath + @"\" + fileName + ".zip";
zipFolderDetails.Add(destFilePath);
//// Zipping the script file
System.IO.Compression.ZipFile.CreateFromDirectory(scriptPath, destFilePath, CompressionLevel.Fastest, false); // <--- Exception here
return zipFolderDetails;