Copy a file from client to server

  • Thread starter Thread starter annamanthadoo
  • Start date Start date
A

annamanthadoo

can anyone help me
i need to copy a file (.txt) from a client to a sever in C#
 
can anyone help me
i need to copy a file (.txt) from a client to a sever in C#

a couple of different techniques, depending on the situation.

You didn't say if the server is in the same domain as the client. In other
words, is this inside a corporate network? If so, simply use UNC path names
to copy the file using built-in methods in the framework. See
System.IO.File.Copy
http://msdn2.microsoft.com/en-us/library/system.io.file.copy(VS.80).aspx

If you are on different networks, then you need the server to have a
protocol running to accept the file. Two most common are FTP and HTTP (Web
Server).

For FTP, see this:
http://msdn2.microsoft.com/en-us/library/system.net.ftpwebrequest(VS.80).aspx

If you want to upload to a web server, then you will need to post the file
to the web server. Since you have client code, you won't be doing this from
a web page, but that doesn't mean you cannot use the web protocols. If you
want to look into this route, start with:
http://msdn2.microsoft.com/en-us/library/system.net.webclient(VS.80).aspx

I hope this helps,

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
 
Back
Top