如何在C#中打开网络共享

时间:2013-07-17 20:33:56

标签: c# login passwords local-network

我试图在C#中编写一个程序,在我的本地网络上打开网络共享。我遇到的问题是越过网络共享的用户登录。

通常在Windows中我只能\ 192.168.101.10输入用户名“nick”密码“nick”

所以我的代码如下

 void FolderPathList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
    {
        //throw new NotImplementedException();

        ComputerModel selectedCm = (ComputerModel)FolderPathList.SelectedItem;
        string uname = "nick";
        System.Security.SecureString password= new System.Security.SecureString("nick");
        if (CaptureDevices.IsChecked != true) System.Diagnostics.Process.Start("explorer.exe", uname, password, "\\\\192.168.101."+selectedCm.IP+"\\ppt");
        if (CaptureDevices.IsChecked != false) System.Diagnostics.Process.Start("explorer.exe", uname, password, "\\\\192.168.101."+selectedCm.IP+"\\c$\\users\\nick\\desktop");
    }

如果我只是

,它的效果绝对正常
 void FolderPathList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
    {
        //throw new NotImplementedException();

        ComputerModel selectedCm = (ComputerModel)FolderPathList.SelectedItem;
                    if (CaptureDevices.IsChecked != true) System.Diagnostics.Process.Start("explorer.exe", "\\\\192.168.101."+selectedCm.IP+"\\ppt");
        if (CaptureDevices.IsChecked != false) System.Diagnostics.Process.Start("explorer.exe", "\\\\192.168.101."+selectedCm.IP+"\\c$\\users\\nick\\desktop");
    }

但是我首先必须首先点击本地网络中的每台计算机,输入一次用户名和密码,然后计算机才会记住它。然而,每当我关闭并重新开始备份时,我每次都必须手动完成。我做错了吗?

0 个答案:

没有答案