Get file to FileStream from remote path with another user credentials

后端 未结 2 1018
再見小時候
再見小時候 2020-12-18 07:39

In my application I use FileStream to read from a file, that is on the fileshare somewhere in the network. So my remoteFilePath variable is somethi

相关标签:
2条回答
  • 2020-12-18 08:27

    Thank you for your answers. Since the share was in another domain, it was not so easy to impersonate.

    I found another, easier solution. I mapped a network drive, and checked the option Connect using different credentials. Then I connect to this drive instead of the remote path.

    string mappedFilePath = filePath.Replace(@"\\computername\", @"Y:\")
    

    and use this new string in FileStream constructor.

    0 讨论(0)
  • 2020-12-18 08:27

    You should use impersonation. More info at http://msdn.microsoft.com/en-us/library/w070t6ka.aspx

    0 讨论(0)
提交回复
热议问题