• Earn real money by being active: Hello Guest, earn real money by simply being active on the forum — post quality content, get reactions, and help the community. Once you reach the minimum credit amount, you’ll be able to withdraw your balance directly. Learn how it works.

C# [C#] Upload a file to your FTP server!

Status
Not open for further replies.

sQuo

~ KillmeMories ~
Shadow
User
Joined
Oct 16, 2011
Messages
5,851
Reputation
0
Reaction score
22,904
Points
688
Credits
0
‎13 Years of Service‎
24%
A simple function to upload a file to your/other's FTP server:

Code:
>public static void Upload(string ftpServer, string userName, string password, string filename)
   {
   using (System.Net.WebClient client = new System.Net.WebClient())
   {
   client.Credentials = new System.Net.NetworkCredential(userName, password);
   client.UploadFile(ftpServer + "/" + new FileInfo(filename).Name, "STOR", filename);
   }
   }
Use:

Code:
>Upload("ftp://myserver.com", "CaptainBri", "MyPass", "C:\\File.doc");
 
Status
Not open for further replies.
Back
Top