Я пытаюсь закрепить файл с помощью библиотеки DotNetZip. Я читаю путь из файла и сохраняю zip в этот файл. Но программа вылетает и бросает. Это мой код:Доступ запрещен .tmp path
using (ZipFile zip = new ZipFile())
{
zip.AddDirectory(dir + "\\OUTPUT_FOLDERS");
StreamReader sr = new StreamReader(dir + "\\Tools\\SettingsForPath");
string path = sr.ReadToEnd();
sr.Close();
zip.Save(path + "\\SavedZip.zip");
Directory.Delete(dir + "\\OUTPUT_FOLDERS", true);
}
и вот моя ошибка:
System.UnauthorizedAccessException: Access to the path 'C:\Users\DotNetZip-nvan5kb5.tmp' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode)
at Ionic.Zip.SharedUtilities.CreateAndOpenUniqueTempFile(String dir, Stream& fs, String& filename)
at Ionic.Zip.ZipFile.get_WriteStream()
at Ionic.Zip.ZipFile.Save()
at Ionic.Zip.ZipFile.Save(String fileName)
Эта папка не может существовать. Фактически, этот диск может не существовать. См. Мой ответ. –
Да. Возможно, поэтому я сказал, что пытаюсь установить известную папку, используя свойство 'TempFileFolder' объекта' ZipFile'. – Sameer