C# and file system

  • Thread starter Thread starter George Varelas
  • Start date Start date
G

George Varelas

Hi.
Can anyone help me with the following problem?
I have a desktop application. The language is C#. I want to access a
directory on a server through this application. Not with http or ftp (using
the 'directory' object). The problem is that I am not user of this server.
Even if I was (I can do that) I do not login in this server. How can I force
the server to prompt me for a login and a password or even better how can I
send these crendentials with a command in order to get access the file
system. Am I using the wrong object? If yes what object can I use?

Thank you in advance.

George Varelas
 
George,

If you were a user on the domain where the server is located, you could
imitate that user by making a call to the LogonUser API function in the
Win32 API. Once you have a handle, you can use the WindowsIdentity class to
impersonate that handle (through a call to the Impersonate method). The
documentation for the Impersonate method will show you how to do this.

Once you do this, you can use the classes in the System.IO namespace to
perform the operations on the files that you need to perform.

Hope this helps.
 
Back
Top