生活本来就刺激 2016-06-05 09:38 采纳率: 0%
浏览 8754

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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog