C# .NET - FtpRequest - Asked By samaira samaira on 12-Mar-12 01:14 AM

My task is , read the data from temp file and copy to FTPpath.
when the file is getting copied to FTP, it should be readonly or not accesible ( other source sholudn't be able to access the file). once the file is copied to FTP it can be accessed by other source .
I have tried both UsePassive =true& false, KeepAlive =true& false

FtpWebRequest reqFTP;
reqFTP.UsePassive = false;
reqFTP.KeepAlive = true;
D Company replied to samaira samaira on 12-Mar-12 11:01 AM
The Properties u have used , should work m not sure why it is not working for u , could u please post the complete code if possible, alternatively u can go through these post from different site , having complete step by step process




Hope this helps
[)ia6l0 iii replied to samaira samaira on 12-Mar-12 02:12 PM
The UsePassive command doesn't work for the purpose you want it to. It simply requests the FTP server that you connected at first place, to listen on a port instead of the command. 

See MSDN for more information on this command - http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.usepassive.aspx

Back to your original question, it is for your clients to decide when they should download the files from the ftp server (perhaps, a text file indicating that the upload is complete?). You can only mark it readonly with the default read access though. 

A simpler option over the FTPRequest is using the WebClient. See the following example. 

using (System.Net.WebClient client = new System.Net.WebClient())
      client.Credentials = new System.Net.NetworkCredential("scott", "pass123));
      client.UploadFile(Path.Combin(ftpServer, filename), "upload", filename);

Hope this helps.