请问,在C#中能不能操作另一台电脑上的非共享文件夹下的文件

fhyin 2005-09-26 08:46:49
请问,在C#中能不能操作另一台电脑上的非共享文件夹下的文件
...全文
242 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
xghim 2005-09-26
  • 打赏
  • 举报
回复
用WMI对象可以实现。

private void CreateProcess(string stringCommandLine)
{
//Set up a handler for the asynchronous callback
ManagementOperationObserver observer = new ManagementOperationObserver();
completionHandler.MyHandler completionHandlerObj = new completionHandler.MyHandler();
observer.ObjectReady += new ObjectReadyEventHandler(completionHandlerObj.Done);

string stringMachineName = "";

//Connect to the remote computer
ConnectionOptions co = new ConnectionOptions();

if (radioMachine.Checked == true)
{
stringMachineName = "localhost";
}
else
{
stringMachineName = textIP.Text;
}

if (stringMachineName.Trim().Length == 0)
{
MessageBox.Show("Must enter machine IP address or name.");
return;
}

//get user and password
if (textUserID.Text.Trim().Length > 0)
{
co.Username = textUserID.Text;
co.Password = textPassword.Text;
}

//Point to machine
System.Management.ManagementScope ms = new System.Management.ManagementScope("\\\\" + stringMachineName + "\\root\\cimv2", co);
//get process path
ManagementPath path = new ManagementPath( "Win32_Process");

//Get the object on which the method will be invoked
ManagementClass processClass = new ManagementClass(ms,path,null);

//Status
updateStatus("Create process " + stringCommandLine + ".");

//Create an array containing all arguments for the method
object[] methodArgs = {stringCommandLine, null, null, 0};

//Execute the method
processClass.InvokeMethod (observer, "Create", methodArgs);

//wait until invoke method is complete or 5 sec timeout
int intCount = 0;
while (!completionHandlerObj.IsComplete)
{
if (intCount > 10)
{
MessageBox.Show("Create process timed out.", "Terminate Process Status");
break;
}
//wait 1/2 sec.
System.Threading.Thread.Sleep(500);

//increment counter
intCount++;
}

if (intCount != 10)
{
//InvokeMethod did not time out
//check for error
if (completionHandlerObj.ReturnObject.Properties["returnValue"].Value.ToString() == "0")
{
//refresh process list
this.Refresh();
}
else
{
MessageBox.Show("Error creating new process.", "Create New Process");
}
}

//Status
updateStatus("Ready");
this.Update();
}
conan19771130 2005-09-26
  • 打赏
  • 举报
回复
用socket客户端可以,只是要编服务端
fhyin 2005-09-26
  • 打赏
  • 举报
回复
有登录的id和password,该怎么做呢
有源码吗?
谢谢
fhyin 2005-09-26
  • 打赏
  • 举报
回复
應該可以,但是沒試過,你可以做一個網絡磁碟映射,(這個需要知道对方帐号和密码) 如H
然後直接直接對H路徑操作,和訪問本機是一樣的

*********************

網絡磁碟映射
不是也需要把文件共享吗?

coffeeant 2005-09-26
  • 打赏
  • 举报
回复
可以,但是你要有登录的id和password,当然如果你发现了漏洞,呵呵,就不需要了.
dragonfly001 2005-09-26
  • 打赏
  • 举报
回复
在知道对方管理员帐号和密码的情况下,在C#中能不能操作另一台电脑上的非共享文件夹下的文件
有源代码吗
//*****************************************************************************
應該可以,但是沒試過,你可以做一個網絡磁碟映射,(這個需要知道对方帐号和密码) 如H
然後直接直接對H路徑操作,和訪問本機是一樣的
fhyin 2005-09-26
  • 打赏
  • 举报
回复
在知道对方管理员帐号和密码的情况下,在C#中能不能操作另一台电脑上的非共享文件夹下的文件
有源代码吗
kisshere 2005-09-26
  • 打赏
  • 举报
回复
yeah, hehe
TechEye 2005-09-26
  • 打赏
  • 举报
回复
IPC$共享,不过要知道对方管理 员账号
zwfhome1 2005-09-26
  • 打赏
  • 举报
回复
可能通过WINSOCK实现,不过麻烦些

也可以这么做,不知可不可以,
共享时共享名后加上“$”,这些共享时别人无法看见,是隐藏的共享,访问时用共享名后加“$”
RedComet2005 2005-09-26
  • 打赏
  • 举报
回复
能够操作其他机器的文件主要是看你当前机器是否具有修改该台机器指定文件的NT权限,开了共享只是默认将修改权限赋予了User而已,同理,将其他文件夹的修改权限设得低点应该也是可以进行操作的。
云涛 2005-09-26
  • 打赏
  • 举报
回复
先写一个程序,在另一太电脑上运行,然后对这个程序发送指定的指令
张赐 2005-09-26
  • 打赏
  • 举报
回复
传说中的木马????

111,120

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧