Get file to FileStream from remote path with another user credentials

Viewed 31097

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 something like: \\computername\folder\file.pdf

FileStream fileStream = new FileStream(remoteFilePath, FileMode.Open, FileAccess.Read, FileShare.None, 1024 * 1024)

Unfortunately, the user that I'm running this application with (that I'm logged into the PC with) does not have access to this fileshare. I have another user (domain, login & password), that has access to those files.

Is it possible to use the other user credentials to get a file to filestream? Can I impersonate the user only to get a file, and then continue with my own user?

2 Answers
Related