Question

hi i am using the following code but it giving an error

 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");
        }

but i am getting an error illegal characters in path.

I am not understanding how to do that.

Was it helpful?

Solution

This string:

"D:\\Folder\test.docx"

Is treating the slashes ('\') as escape characters - use this instead:

@"D:\Folder\test.docx"

Or (more messy), double escape to be treated as a literal slash:

"D:\\Folder\\test.docx"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top