Click here to Skip to main content
14,580,516 members
Rate this:
Please Sign up or sign in to vote.
See more:
So I have this ftp upload, upload file from my local to ftp folder, but my problem is, I need to refresh the FTP Folder to view my uploaded file.

Pls help.

What I have tried:

using System.Net;
using System.IO;

//Create FTP request
FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(ftpAdd + "/" + Path.GetFileName(filePath));

request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential(username, password);
request.UsePassive = true;
request.UseBinary = true;
request.KeepAlive = true;

//Load the file
FileStream stream = File.OpenRead(filePath);
byte[] buffer = new byte[stream.Length];

stream.Read(buffer, 0, buffer.Length);
stream.Close();

//Upload file
Stream reqStream = request.GetRequestStream();
reqStream.Write(buffer, 0, buffer.Length);
reqStream.Close();
                    
request = null;
MessageBox.Show("Uploaded Successfully");
Posted
Updated 12-Dec-18 0:49am
Comments
Dave Kreskowiak 12-Dec-18 0:36am
   
You're going to have to describe what "refresh the FTP Folder" means. Does that mean you have to hit F5 in the Explorer window on the server to see the file? Does it mean you have to refresh the view on the client after you upload the file to show the current files on the remote FTP server? What?
chimcham 12-Dec-18 0:49am
   
Yes Sir, correct. I have to right click then click Refresh button in the explorer..
Dave Kreskowiak 12-Dec-18 8:30am
   
You don't have any control over that in your code.
chimcham 12-Dec-18 22:06pm
   
Ohh i see, if that's the case.. then i'll rest my case.. thanks for your reply..

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100