使用C#的FTP(刷新当前目录) [英] FTP(Refresh current directory) using C#

查看:123
本文介绍了使用C#的FTP(刷新当前目录)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,
我做了一个ftp文件浏览器,但不幸的是,当刷新当前目录为被动错误模式时,如果不输入它,它将无法正常工作.

Dear,
I have made a ftp file explorer but unfortunately it won''t work when refresh current directory passive false mode not enter.

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

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.

}


刷新当前目录不起作用,原因是为什么我的列表视图保留了先前删除的文件并创建了异常.
请告诉问题是什么.我正在尝试很多.如果您不明白,请告诉我如何刷新当前目录并在该目录中获取新的ftp文件
马哈茂德
软件工程师


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

推荐答案

我要猜测您正在使用
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.


这篇关于使用C#的FTP(刷新当前目录)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆