如果是局域网上可以通过wmi来实现, 先使用Wmi开通连接,再Copy文件using System; using System.Management;// This example demonstrates how to connect to remote machine // using supplied credentials. class Sample_ConnectionOptions { public static int Main(string[] args) { ConnectionOptions options = new ConnectionOptions(); options.Username = UserName; //could be in domain\user format options.Password = SecurelyStoredPassword; ManagementScope scope = new ManagementScope( "\\\\servername\\root\\cimv2", options); try { scope.Connect(); ManagementObject disk = new ManagementObject( scope, new ManagementPath("Win32_logicaldisk='c:'"), null); disk.Get(); } catch (Exception e) { Console.WriteLine("Failed to connect: " + e.Message); } return 0; } }
以前做的是
服务器上的text文件的修改
读写都是服务器上作的,不用下载的
先使用Wmi开通连接,再Copy文件using System;
using System.Management;// This example demonstrates how to connect to remote machine
// using supplied credentials.
class Sample_ConnectionOptions
{
public static int Main(string[] args) {
ConnectionOptions options = new ConnectionOptions();
options.Username = UserName; //could be in domain\user format
options.Password = SecurelyStoredPassword;
ManagementScope scope = new ManagementScope(
"\\\\servername\\root\\cimv2",
options);
try {
scope.Connect();
ManagementObject disk = new ManagementObject(
scope,
new ManagementPath("Win32_logicaldisk='c:'"),
null);
disk.Get();
}
catch (Exception e) {
Console.WriteLine("Failed to connect: " + e.Message);
}
return 0;
}
}