我用c#写了一段从ftp服务器下载文件的代码,下载3g以下的文件一切正常,当下载3g以上文件时,本机上复制到了ftp服务器上的文件 但是没有下载 文件大小为0kb
然后我用ftp软件去下载 无论文件大小是多少都能够正常下载。有人说时ftp服务器防火墙的问题,有人说是ie有限制不能下载大文件,请有知道的能帮助看一下怎么解决或者设置吗?

解决方案 »

  1.   

    我是通过资源管理器下载的 没有用ie下载,估计不是ie下载限制。
      

  2.   

    不知道你用的是什么方法,我用WebClient下载了一个4.6G的电影都是正常的,就是速度慢了点。
    服务器操作系统2003,FTP用的是FileZilla。
    代码如下,窗体上放两个Button和一个Label控件。    public partial class FtpForm : Form
        {
            WebClient _ftpClient;        public FtpForm()
            {
                InitializeComponent();            _ftpClient = new FtpClient();
                _ftpClient.DownloadProgressChanged +=
                    new DownloadProgressChangedEventHandler(_ftpClient_DownloadProgressChanged);
                _ftpClient.DownloadFileCompleted +=
                    new AsyncCompletedEventHandler(_ftpClient_DownloadFileCompleted);
            }        void _ftpClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
            {            if (e.Error != null)
                    MessageBox.Show("Error downloading file: " + e.Error.Message, "Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                else
                    if (e.Cancelled)
                    {
                        MessageBox.Show("Download progress has been cancelled.", "Warning",
                            MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        var dr = MessageBox.Show("Download completed, open it now?", "Completed",
                            MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                        if (dr == System.Windows.Forms.DialogResult.Yes)
                            System.Diagnostics.Process.Start(((DownloadState)e.UserState).FileName);
                    }
            }        void _ftpClient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
            {
                // 貌似不能获得文件的长度,所以进度是没有意义的,只能显示已经下载的字节数。
                DownloadState state = (DownloadState)e.UserState;
                double speed;
                speed = e.BytesReceived / state.Timer.Elapsed.TotalSeconds / 1024.0;
                label1.Text = e.BytesReceived.ToString("N0") + " (" + speed.ToString("N2") + "KB/s)";
            }        private void button1_Click(object sender, EventArgs e)
            {
                if (!_ftpClient.IsBusy)
                {
                    Uri uri = new Uri("ftp://username:passsword@host/path/filename.ext");
                    StartDownload(uri, "c:\\temp\\download.mkv");
                }
            }        private void StartDownload(Uri url, string saveAs)
            {
                if (!_ftpClient.IsBusy)
                {
                    DownloadState state = new DownloadState();
                    state.FileName = saveAs;
                    state.Timer.Start();
                    _ftpClient.DownloadFileAsync(url, saveAs, state);
                }
                else
                    MessageBox.Show("Downloading file now.");
            }        protected override void OnFormClosed(FormClosedEventArgs e)
            {
                base.OnFormClosed(e);            _ftpClient.Dispose();
            }        private void button2_Click(object sender, EventArgs e)
            {
                if (_ftpClient.IsBusy)
                    _ftpClient.CancelAsync();
            }        class DownloadState
            {
                public DownloadState()
                {
                    _timer = new Stopwatch();
                }            private Stopwatch _timer;            public Stopwatch Timer
                {
                    get { return _timer; }
                }            private string _fileName;            public string FileName
                {
                    get { return _fileName; }
                    set { _fileName = value; }
                }        }        class FtpClient : WebClient
            {
                public FtpClient()
                {
                }            protected override WebRequest GetWebRequest(Uri address)
                {
                    FtpWebRequest request = (FtpWebRequest)base.GetWebRequest(address);
                    // 由于是内网,不使用PASV模式。
                    request.UsePassive = false;
                    return request;
                }        }
        }