c#对路径访问被拒绝怎么办?

从ftp服务器上下载东西到本地,报错对路径访问被拒绝。
这是下载函数
public void DownloadFile(string localFile, string remoteFile)
{
FtpWebRequest ftp = CreateFtpRequest(string.Format("{0}/{1}", _ftpURI, remoteFile));
ftp.Method = WebRequestMethods.Ftp.DownloadFile;
using (FtpWebResponse response = (FtpWebResponse)ftp.GetResponse())
{
using (Stream stream = response.GetResponseStream())
{
byte[] buffer = new byte[2048 * 8];
using (FileStream fs = new FileStream(localFile, FileMode.Create, FileAccess.Write))
{
int count = stream.Read(buffer, 0, buffer.Length);
while (count > 0)
{
fs.Write(buffer, 0, count);
count = stream.Read(buffer, 0, buffer.Length);
}
fs.Close();
}
stream.Close();
}
response.Close();
}
MessageBox.Show("下载完成!");
}

            执行如下
                    private void skinButton2_Click(object sender, EventArgs e)
    {
        string localPath = "";
        FolderBrowserDialog fd = new FolderBrowserDialog();
        if (fd.ShowDialog() == DialogResult.OK)
        {
            localPath = fd.SelectedPath;
        }
        FTPHelper user = new FTPHelper("127.0.0.1", "user88", "123");
        MessageBox.Show(localPath);
        user.DownloadFile(localPath, fileName);

    }
            求大神帮忙看一下好吗

0个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐