您的位置:首页 > 理论基础

本地的一个文件复制到远程计算机上

2009-11-12 23:02 281 查看
先建立授权访问,
使用WMI
using System;
using System.Management;

class Sample_ConnectionOptions
{
public static int Main(string[] args) {
ConnectionOptions options = new ConnectionOptions();
options.Username = 用户名; //could be in domain/user format
options.Password = 密码;
ManagementScope scope = new ManagementScope(
"////servername//root//cimv2",
options);
try {
scope.Connect();
ManagementObject disk = new ManagementObject(
scope,
new ManagementPath("Win32_logicaldisk='c:'"),
null);
disk.Get();
//接着就可以拷文件了,就象在本地操作一样,不过要加上网络路径
File.Copy(@"//remotepc/c:/te.txt","c://te1.txt");
}
catch (Exception e) {
Console.WriteLine("Failed to connect: " + e.Message);
}
return 0;
}
}

再复制文件, http://blog.csdn.net/zhzuo/archive/2005/03/08/315125.aspx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐