【发布时间】:2017-01-07 13:09:34
【问题描述】:
我需要复制或读取假脱机文件。但是当我尝试阅读/复制它时。我收到以下错误。
System.UnauthorizedAccessException:访问路径 'C:\Windows\System32\spool\PRINTERS\00007.SPL' 被拒绝。在 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
在 System.IO.File.InternalCopy(字符串源文件名,字符串 destFileName,布尔覆盖,布尔检查主机)在 System.IO.File.Copy(String sourceFileName, String destFileName) 在 WDISYS.wfPrintServerLogin.Addedtest(对象发送者,PrintJobEventArgs e) 在 F:\Projects\Asp.Net\AT\A2Test\WDISYS\WDISYS\wfPrintServerLogin.cs:line 255
我的代码如下:
try
{
string dest = @"C:\Windows\sfwitch\spls";
if (!System.IO.Directory.Exists(@"C:\Windows\sfwitch\spls"))
{
System.IO.Directory.CreateDirectory(@"C:\Windows\sfwitch\spls");
}
string spl_file = (e.PrintJob.JobId).ToString().PadLeft(5, '0');
string printSpoolPath = @"C:\Windows\System32\spool\PRINTERS";
printSpoolPath = System.IO.Path.Combine(printSpoolPath, spl_file) + ".SPL";
System.IO.File.Copy(printSpoolPath, System.IO.Path.Combine(dest, spl_file) + ".SPL");
}
catch (Exception ex80)
{
LogHelper.WriteErrorLog("Spool file create problem", ex80);
}
【问题讨论】:
-
你试过以管理员身份运行 Visual Studio 吗?
-
它发生在客户端电脑上。它适用于我的开发电脑。
-
那么用户无权访问该位置。您的客户端需要尝试以管理员身份运行应用程序。
-
客户端以管理员身份运行程序。这仍然在发生。为什么我在这里问。