Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello,

I have written this code it is giving error "Illegal characters in path."

C#
WebClient client = new WebClient();
            string Path = @"111.11.111.111:111\abc\abc\abc\";            
            Byte[] buffer = client.DownloadData(Path + lblresult.Text);
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-length", buffer.Length.ToString());
            Response.BinaryWrite(buffer);


please Help..............
Posted

Member 11014751 wrote:

Folder is on server and i want to access that... and that is a IP address...
I repeat once again: ':' is and invalid character for path.

Here is your problem: don't mix up URI scheme with other elements of URI, learn what part is what:
http://en.wikipedia.org/wiki/URI_scheme[^],
http://en.wikipedia.org/wiki/Uniform_resource_identifier[^],
http://en.wikipedia.org/wiki/Uniform_resource_locator[^].

Last referenced article contains allowed characters.

—SA
 
Share this answer
 
Comments
Member 11014751 30-Sep-14 5:25am    
Please guide me what do i write in replace of this line :
string Path = @"111.11.111.111:111\abc\abc\abc\";
Sergey Alexandrovich Kryukov 30-Sep-14 9:51am    
I have no idea what is that, but it should be prefixed with URI schema:
http://
ftp://
And it's '/', not '\'
—SA
Illegal character is ':'. After all, learn what characters are valid and what not!

—SA
 
Share this answer
 
Comments
Member 11014751 30-Sep-14 3:24am    
Folder is on server and i want to access that... and that is a IP address ..
Sergey Alexandrovich Kryukov 30-Sep-14 3:31am    
See Solution 2. And — read!
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900