Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Dear,
I have made a ftp file explorer but unfortunately it won't work when refresh current directory passive false mode not enter.
C#
private void bgworkerImporter_DoWork(object sender, DoWorkEventArgs e)
{
    BackgroundWorker worker = sender as BackgroundWorker;
    for (; ; )
    {
        if (IsbusyImporter == false)
        {
            //working here
           // ftpSession.CurrentDirectory.Refresh();
            StartDownload();
        }
        if ((worker.CancellationPending == true))
        {
            e.Cancel = true;
            break;
        }
        else
        {
            // Perform a time consuming operation and report progress.
            System.Threading.Thread.Sleep(500);
        }
    }
}

then
C#
public void StartDownload()
{
    //working here
    int files = ftpSession.CurrentDirectory.Files.Count();
    foreach (FtpFile file in ftpSession.CurrentDirectory.Files)
    {
      //  string Splitfile = file.Name.ToString();
      //  string[] Allsplitfile = Splitfile.Split('.');

        transferProgressBar.Value = 0;
        try
        {
            if (files >= 0)
            {
                // working here
                DownloadFile(file.Name.ToString());
                // Deletefile From FTP Directory
                if (IsSuccess == "Success")
                {
                    DeleteFTPFile(file.Name.ToString());
                }
            }
            else
            {
                IsbusyImporter = false;
            }


        }
        catch (Exception ex)
        {
            MessageBox.Show(IsDelete);
        }
    }
    IsbusyImporter = true;
   ftpSession.CurrentDirectory.Refresh();// here is problem refresh was not worked.

}

Refreshing current directory isn't work for why my listview kept previous deleted file and exception created.
Please tell what is the problem.I am trying a lot.if u don't understand then tell me how can i refresh current directory and get new ftp file in that directory
Mahmud
software Engineer
Posted
Updated 27-Oct-10 0:01am
v3

1 solution

I'm going to guess that you are using the code from http://www.codeproject.com/KB/dotnet/dotnetftp.aspx[^] if you had of looked through the sample code provided in the article you would have seen that after the Refresh call there is a call back to the function that fills the ListView.
ftpSession.CurrentDirectory.Refresh();
FillListView(); //This calls the code that populates the ListView

Lastly if you are having problems with code from an article it is usually best if you post your question there.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900