如何使用C#将文件从ftp下载到本地目录?

如何使用C#将文件从ftp下载到本地目录?,ftp,webclient,credentials,transfer,Ftp,Webclient,Credentials,Transfer,嗨,我正在使用下面的代码,但它给出了一个错误 using (WebClient ftpClient = new WebClient()) { ftpClient.Credentials = new System.Net.NetworkCredential("username", "password"); ftpClient.DownloadFile("ftp://path.com/Business Plan.docx", "D:\

嗨,我正在使用下面的代码,但它给出了一个错误

 using (WebClient ftpClient = new WebClient())
        {
            ftpClient.Credentials = new System.Net.NetworkCredential("username", "password");
            ftpClient.DownloadFile("ftp://path.com/Business Plan.docx", "D:\\Folder\test.docx");
        }
但是我在路径中得到一个错误非法字符

我不明白怎么做。

此字符串:

"D:\\Folder\test.docx"
正在将斜杠(“
\
”)视为转义字符-请改用此字符:

@"D:\Folder\test.docx"
或者(更混乱),将双转义视为文字斜杠:

"D:\\Folder\\test.docx"
此字符串:

"D:\\Folder\test.docx"
正在将斜杠(“
\
”)视为转义字符-请改用此字符:

@"D:\Folder\test.docx"
或者(更混乱),将双转义视为文字斜杠:

"D:\\Folder\\test.docx"
此字符串:

"D:\\Folder\test.docx"
正在将斜杠(“
\
”)视为转义字符-请改用此字符:

@"D:\Folder\test.docx"
或者(更混乱),将双转义视为文字斜杠:

"D:\\Folder\\test.docx"
此字符串:

"D:\\Folder\test.docx"
正在将斜杠(“
\
”)视为转义字符-请改用此字符:

@"D:\Folder\test.docx"
或者(更混乱),将双转义视为文字斜杠:

"D:\\Folder\\test.docx"

如果使用
@
前缀,则还应删除额外的\before“folder”如果使用
@
前缀,则还应删除额外的\before“folder”如果使用
@
前缀,则还应删除额外的\before“folder”如果使用
@
前缀,则还应删除“文件夹”之前的额外\