将文件复制到另一台服务器 [英] Copy file to another server

查看:87
本文介绍了将文件复制到另一台服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好..我下面有一个代码可以将文件复制到另一台服务器,但是它不起作用..此显示消息:无效的URI:无法确定URI的格式
谁能帮我...
字符串fileName ="Image1.JPG";
尝试
{
WebClient客户端=新的WebClient();

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

}
catch(ex ex例外)
{
Console.WriteLine(ex.Message);
}
Console.Read();

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();

推荐答案

查看此"URI":"\\ 172.22.1.34 \\ D:\\ File \\ test.JPG" — 它怎么可能有效?
您始终可以了解URL并了解其结构: http://en.wikipedia.org/wiki/URL [ ^ ].

但是,所写内容表明,即使在普通用户(而不是软件开发人员)的级别上,您也不了解Web的工作方式和HTTP服务器的功能.

在如此深层次的混乱中,很难解释它……好吧,您认为HTTP服务器显示文件吗?不完全是,它显示了不同内容类型的网页,只有其中一些映射在文件系统上.甚至文件系统中存在的文件,以及由HTTP服务器基于一对一对应关系将其转换为页面的文件,其名称与它们在本机文件系统中的名称也不相同.这是一个安全问题:客户端无法直接访问服务器的文件系统;客户端不能直接访问服务器的文件系统.服务是从文件系统中抽象出来的.作为URL的文件是相对于某些网站的根目录路径命名的,并且根目录对应于scheme://domain:port部分(根据上面引用的文章,请参见).此外,默认索引文件也可以包含在内.

例如:"http://www.myDomain.com/someFile.html"对应于放置在网站根目录中的文件"someFile.html",而"https://www.myDomain.org:4291/" "—到"index.html"或"default.aspx"之类的文件,或位于(另一个)站点根目录中的类似文件(取决于服务器选项)(由于架构和端口不同,可能与第一个示例不同).

—SA
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


这篇关于将文件复制到另一台服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆