归档正在办公室和网站上的远程桌面(同事)上工作。我测试了它。
我正在写一项服务,我也需要它。这不适用于我的机器,我远程工作并通过VPN连接。登录此计算机的用户属于该域。
现在,在压缩之前,我正在使用特殊用户帐户进行冒充。如果我不这样做,那么这甚至不会在网站上工作。
以下是我得到的例外情况。我该如何解决?
System.IO.FileLoadException was caught
Message=Could not load file or assembly 'ICSharpCode.SharpZipLib, Version=0.85.3.365, Culture=neutral, PublicKeyToken=1b03e6acf1164f73' or one of its dependencies. Access is denied.
Source=Project.Helpers
FileName=ICSharpCode.SharpZipLib, Version=0.85.3.365, Culture=neutral, PublicKeyToken=1b03e6acf1164f73
FusionLog==== Pre-bind state information ===
LOG: User = Unknown
LOG: DisplayName = ICSharpCode.SharpZipLib, Version=0.85.3.365, Culture=neutral, PublicKeyToken=1b03e6acf1164f73
(Fully-specified)
LOG: Appbase = file:///C:/Users/UserPC/Documents/DATA/Projects/ProjectHelperApps/ProjectHelper/TestResults/UserPC_UserPCJ-LAPTOP 2012-08-03 15_50_57/Out
LOG: Initial PrivatePath = NULL
Calling assembly : Project.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\UserPC\Documents\DATA\Projects\ProjectHelperApps\ProjectHelper\TestResults\UserPC_UserPCJ-LAPTOP 2012-08-03 15_50_57\Out\Project.Helpers.Tests.DLL.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: ICSharpCode.SharpZipLib, Version=0.85.3.365, Culture=neutral, PublicKeyToken=1b03e6acf1164f73
LOG: Attempting download of new URL file:///C:/Users/UserPC/Documents/DATA/Projects/ProjectHelperApps/ProjectHelper/TestResults/UserPC_UserPCJ-LAPTOP 2012-08-03 15_50_57/Out/ICSharpCode.SharpZipLib.DLL.
ERR: A fatal error occurred when retrieving next codebase for download (hr = 0x80070005).
StackTrace:
at Project.Helpers.IO.ZipUtility.ZipFiles(String toArchivePath, String destDir, String archiveName, String password, Boolean isDir)
at Project.Helpers.IO.FileSystem.ArchiveDirectory(String dirToArchive, String destDir, String archiveName)
InnerException:
以下是存档方法:
public bool ArchiveDirectory(string dirToArchive, string destDir, string archiveName)
{
bool ok = false;
if (!String.IsNullOrWhiteSpace(dirToArchive) &&
!String.IsNullOrWhiteSpace(destDir) &&
!String.IsNullOrWhiteSpace(archiveName) &&
DirectoryExists(dirToArchive))
{
ok = true;
//create destination directory
if (!DirectoryExists(destDir))
ok = CreateDirectory(destDir);
}
if (ok)
{
//Archive Name should have .ZIP extension, if not, add it
if (!archiveName.ToLowerInvariant().Contains(".zip"))
archiveName = archiveName + ".ZIP";
//Check that the Zip file already exists, if it does then delete it
if (FileExists(Path.Combine(destDir, archiveName)))
ok = FileDelete(Path.Combine(destDir, archiveName));
}
if (ok)
{
//Start Impersonation
_impersonate.DoImpersonate();
//Using ZipUtility Class to Zip Directory
try
{
ZipUtility.ZipFiles(dirToArchive, destDir, archiveName, "", true);
}
catch (SystemException ex)
{
ok = false;
}
//end impersonation
_impersonate.Dispose();
}
if (ok)
{
//double check that the archived directory exists
ok = FileExists(Path.Combine(destDir, archiveName));
}
return ok;
}
请注意,模拟正在运行,因为CreateDirectory,FileExists和FileDelete正在运行,没有任何问题。在执行相关操作之前,这3种方法首先进行模拟。
感谢您对此进行调查!
答案 0 :(得分:1)
通过以下方式解决问题:
答案 1 :(得分:1)
在C:\ Windows \ Microsoft.NET \ Framework \ ... \ Temporary ASP.NET Files中临时清理文件夹。
希望这可以提供帮助。