Console.Write("\nPlease enter the URI to post data to : "); String uriString = Console.ReadLine();
// Create a new WebClient instance. WebClient myWebClient = new WebClient(); Console.WriteLine("\nPlease enter the fully qualified path of the file to be uploaded to the URI"); string fileName = Console.ReadLine(); Console.WriteLine("Uploading {0} to {1} ...",fileName,uriString);
// Upload the file to the URI. byte[] responseArray = myWebClient.UploadFile(uriString,fileName);
// Decode and display the response. Console.WriteLine("\nResponse Received.The contents of the file uploaded are:\n{0}", System.Text.Encoding.ASCII.GetString(responseArray));
Please, use the search on this forum and use a other favorite search engine to search the world wide web. There are a lot of examples out there, here is a little list:
Using FTP-Class with vb.net
mamad5
Please, does anybody have a sample code in vb.net I would greatly appreciate that.
biren j shah
You have a few options for uploading a file:
1. Use the WebClient class:
Console.Write("\nPlease enter the URI to post data to : ");
String uriString = Console.ReadLine();
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();
Console.WriteLine("\nPlease enter the fully qualified path of the file to be uploaded to the URI");
string fileName = Console.ReadLine();
Console.WriteLine("Uploading {0} to {1} ...",fileName,uriString);
// Upload the file to the URI.
byte[] responseArray = myWebClient.UploadFile(uriString,fileName);
// Decode and display the response. Console.WriteLine("\nResponse Received.The contents of the file uploaded are:\n{0}", System.Text.Encoding.ASCII.GetString(responseArray));
2. Use the FTPWebRequest class:
http://msdn2.microsoft.com/en-us/library/6cxacd61.aspx
To upload a file set FtpWebRequest.Method = WebRequestMethods.Ftp.UploadFile.
Marco Gouveia
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=181460&SiteID=1
munashe