Click here to Skip to main content
15,902,189 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hello.. i have a code below to copy file to another server,, but it doesn't work.. this show message: Invalid URI: The format of the URI Could not be determined
can anyone help me, please...
string fileName = "Image1.JPG";
try
{
WebClient client = new WebClient();

NetworkCredential nc = new NetworkCredential("test", "test1");
Uri copy = new Uri("\\172.22.1.34\\D:\\File\\test.JPG");
client.Credentials = nc;
byte[] arrReturn = client.UploadFile(copy, fileName);
Console.WriteLine(arrReturn.ToString());

}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.Read();
Posted

1 solution

Look at this "URI": "\\172.22.1.34\\D:\\File\\test.JPG" — how it possibly be valid?
You can always read about URL and understand its structure: http://en.wikipedia.org/wiki/URL[^].

However, what you have written suggests that you have no idea on how Web works and what HTTP server does, even on the level of the common user, not a software developer.

At such a deep level of confusion, it's hard to explain it… Well, do you think HTTP server shows files? Not exactly, it shows Web pages of different content types, and only some of them are mapped on the file system. Even the files which exist in a file system and are translated by the HTTP server as pages based on one-to-one correspondence do not come at the same names as their name in their native file system. This is a matter of safety: the client cannot get direct access to the file system of the server; the service is abstracted form the file system. The files as URLs are named relative to some Web site's root path, and the root corresponds to the part scheme://domain:port (in terms of the article referenced above, please see). Also, the default index file can be involved.

For example: "http://www.myDomain.com/someFile.html" corresponds to the file "someFile.html" placed in the root directory of the site, and "https://www.myDomain.org:4291/" — to the file like "index.html" or "default.aspx" or something like that (depending on server options) located in (another) site root (probably different from the first example due to different schema and port).

—SA
 
Share this answer
 
v2
Comments
Ade.Ruyani.Z 18-Jan-12 0:59am    
hello sakryukov,, i mean i want to copy file from my local computer to another computer (server). i still learn about this.. hope u help me to solve this case,, thanks...

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