未经测试的代码,但将类似于:
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);// http://pinvoke.net/default.aspx/advapi32/LogonUser.html IntPtr token;LogonUser("username", "domain", "password", LogonType.LOGON32_LOGON_BATCH, LogonProvider.LOGON32_PROVIDER_DEFAULT);WindowsIdentity identity = new WindowsIdentity(token);WindowsImpersonationContext context = identity.Impersonate();try{ File.Copy(@"c:tempMyFile.txt", @"\serverfolderMyfile.txt", true);}finally{ context.Undo();}


