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

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 gwas 分析-数据质控之过滤稀有突变中出现的问题
    • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
    • ¥15 知识蒸馏实战博客问题
    • ¥15 用PLC设计纸袋糊底机送料系统
    • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
    • ¥15 用C语言输入方程怎么
    • ¥15 网站显示不安全连接问题
    • ¥15 51单片机显示器问题
    • ¥20 关于#qt#的问题:Qt代码的移植问题
    • ¥50 求图像处理的matlab方案