|
2/12/2003 12:13:48 PM
|
Not rated
|
public string MapDrive(string hostName,string path)
{
string driveLet="";
if(NotBlank(hostName))
{
System.Diagnostics.Process tmp=new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo tmp2=new
System.Diagnostics.ProcessStartInfo(
"net","use * \\\\" + hostName + "\\" + path);
tmp2.UseShellExecute=false;
tmp2.RedirectStandardOutput=true;
tmp2.CreateNoWindow=true;
tmp=System.Diagnostics.Process.Start(tmp2);
string strOut=tmp.StandardOutput.ReadToEnd();
tmp.WaitForExit();
Regex re= new Regex(@"Drive\s(?<drive>[A-Z])(:)");
Match m = re.Match(strOut);
if (m.Success)
{
driveLet= m.Groups["drive"].Value;
}
else
{
MessageBox.Show(strOut);
}
}
return driveLet;
}
|
Thats how to create. I'm sure you get the idea
|