好吧,这可能是一个愚蠢的问题,我在为项目使用dotnetzip来压缩pdf,但是我得到的错误是我没有指定要保存的目录,但是我想如果将其设置为这样,我会知道吗?。
DialogResult result = MessageBox.Show(null, "Invalid file or file size has exceeded it max limit of 1MB. Do you wish to compress the file", "File Size Exceeds",MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
string targetDirectory = Job.AttachmentPath + @"\";
string target = Job.AttachmentPath + @"\" + Path.GetFileNameWithoutExtension(filename) + ".zip";
using (ZipFile zip = new ZipFile())
{
zip.AddFile(filename, targetDirectory);
zip.Save();
if (!Directory.Exists(Job.AttachmentPath))
Directory.CreateDirectory(Job.AttachmentPath);
File.Copy(filename, target);
}
}
的值
JOB.AttachmentPath = C:\ Jobs \ 022230
如何使用上面的using语句为目录提供.net zip?我在上述targetDirectory
语句中正确声明了zip.addFile
吗?