The correct way to access files on another machine using C #

I want to read files from different Windows computers on the same network, although this is not part of the same domain. (ASP.NET C # application)
Tried FileStream (cannot authenticate), tried FileWebRequest (returns to FileStream when using file: ///) and impersonation ( support.microsoft.com/kb/306158#4 ) That says that "impersonation failed" on my Vista.
Update: I fixed the "Impersonation" issue. But I still get “Access denied” from another machine, although I have a “mirror” user on both, so the question remains ...
What is the correct approach to this task?

+3
source share
4 answers

This is probably not the answer you are looking for, but you asked for the correct path, so ... join the file server to the domain and grant access to the ASP.NET service account for sharing.

+1
source

I am not sure if this is the right approach, but the way I do it. Assuming you know the login for this computer, I P / Call WNetConnection on the IPC $ object to authenticate with the computer, do my work, then do another P / Invoke to remove the connection to IPC $.

0
source

WebClient. URI, , "file" ( HTTP).

WebClient :

WebClient.DownloadFile(Uri address, string localFile)

:

WebClient.OpenRead(Uri address)

. Uri, , "file".

, , web.config

<authentication mode="Windows" />
<identity impersonate="true" username="[user]" password="[password]"/>

, , .

: ASP.NET 2.0

0

, . "Z:" , . Z:...

0

Source: https://habr.com/ru/post/1714743/


All Articles