how to copy a file from a local machine folder to an FTP folder
Posted on 2013-11-27
I need to copy a text file from a local folder to an ftp folder.
I believe that the steps are:
Read the local file contents into a filestream.
Initiate an FTPWebRequest.
Use a FTPWebRequest method to copy the filestream to the ftp folder.
Here are my source statements:
strSourcePath = "C:\\Develop\\Apps\\StockPro\\Data\\Changes\\";
string strSourceFileName = "Changes.txt";
string strSourceFile = strSourcePath + strSourceFileName;
// Create a filestream object
FileStream fs = new FileStream(strSourceFile, FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(fs);
// Copy the contents of the file to the request stream.
StreamReader sourceStream = new StreamReader("Changes.txt");
byte  fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
// only one column is copied to the request stream.
//Use a FTPWebRequest method to copy the filestream to the ftp folder.