模拟似乎不适用于使用 File.OpenRead() 的 UNC 路径是否有原因?我正在使用CodeProject 的 Impersonation 实用程序:
我有一个用户有权访问我传递给 OpenRead() 的共享。
这是我的代码,它没有访问文件:
try
{
bool canImp = imp.ImpersonateValidUser(impUser, domain, impPwd);
FileStream fs = File.OpenRead(filePath);
logger.Debug("File stream opened...");
byte[] b = new byte[fs.Length];
fs.Read(b, 0, b.Length);
fs.Close();
// code continued