Open a shared file under another user and domain?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a C# console application that needs to read a shared file on a machine in another domain. When the application tries to access the file an exception occurs as the local user does not have permission to access the shared resource. Currently I overcome this problem manually by open the shared folder from the run and put the username and password into the windows authentication dialog then run the application. How can I do it programmatically? 回答1: a) p/invoke LogonUser with LOGON32_LOGON_NEW_CREDENTIALS and create a new WindowsIdentity