连接局域网共享目录

来源:互联网 发布:网络电影仙侠学院影评 编辑:程序博客网 时间:2024/04/30 09:55

第一次连接局域网计算机时,自动填写用户,密码进行登陆,以后就不需在连接了.

//连接网络计算机
        private void ConnectRemoteMachine(string folder,string userName,string password)
        
{
            Process process1 
= new Process();
            
try
            
{
                process1.StartInfo.FileName 
= "net";
                String arguments 
= " use " +folder +" "+ password + " "+"/User:"+userName;
                process1.StartInfo.Arguments 
= arguments;
                process1.StartInfo.WindowStyle 
= System.Diagnostics.ProcessWindowStyle.Hidden;
                process1.Start();
                process1.WaitForExit();
                process1.Close();
            }

            
catch(Exception ex)
            
{
                MessageBox.Show(
"connection fail..."+ex.Message);
            }

        }
 
原创粉丝点击