次のコードを使用してリモート ドライブをマウントしています。
public static void MapDrive()
{
try
{
if (System.IO.Directory.Exists(remoteFolder1)) //"Z:\\"
{
DisconnectDrive(remoteDriveLetter); //"Z:"
}
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "net.exe";
p.StartInfo.Arguments = @" use " + remoteDriveLetter + " " + remoteShareName + " " + userPwd + " /user:" + userName;
//EventLog.WriteEntry("Conversion Service", "Remote drive mapped successfully", EventLogEntryType.Information);
p.Start();
p.WaitForExit();
}
catch (Exception ex6_5)
{
WriteException(ex6_5, "Ex6.5");
}
}
Z ドライブが使用可能で、ファイルをドラッグして Z ドライブに保存できることを確認できますが、次のコードは DirectoryNotFoundException 「パス 'Z:\Default.pptx' の一部が見つかりませんでした」をスローします。
AsyncFileUpload1.SaveAs(remoteFolder + fileName);
remoteFolder の値は「Z:\」で、ファイル名は「Default.pptx」です。
誰か助けてくれませんか?
ありがとう、
りしょう