如何将文本文件从Web服务器复制到另一个网络服务器 [英] How to copy text file from webserver to another network server

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

问题描述

我想使用用户凭据将文本文件从Web服务器复制到另一个网络服务器。



例如:Server.MapPath(Test_File.txt)到\\10.220.120.13\c: \extract

解决方案





试试这个:

  string  filePath =   Test_File.txt; 
try
{
WebClient client = new WebClient();
NetworkCredential nc = new NetworkCredential(userName,password);
File.Copy(filepath, \\\\10.220.120.13 \\文件);
client.Credentials = nc;
byte [] arrReturn = client.UploadFile(addy,filePath);
Console.WriteLine(arrReturn.ToString());
}
catch (例外情况)
{

}


I want to copy the Text file from web server to another network server using user credentials.

Eg: Server.MapPath("Test_File.txt") to "\\10.220.120.13\c:\extract"

解决方案

Hi,

Try this:

string filePath = "Test_File.txt";
try
{
    WebClient client = new WebClient();
    NetworkCredential nc = new NetworkCredential(userName, password);
    File.Copy(filepath, "\\\\10.220.120.13\\Files");
    client.Credentials = nc;
    byte[] arrReturn = client.UploadFile(addy, filePath);
    Console.WriteLine(arrReturn.ToString());
}
catch (Exception ex)
{
   
}


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

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