try
{
// Map a drive
System.Diagnostics.Process.Start(@"C:\WINDOWS\system32\net.exe",
$"use J: {_fileUploadConst.UploadPath} {_fileUploadConst.Password} /user:{_fileUploadConst.UserName}");
// Delay to allow the changs to take effect
Thread.Sleep(2000);
// or use File.Save() etc.
using var stream = new FileStream(fullFilePath, FileMode.CreateNew);
await fileInput.CopyToAsync(stream);
stream.Flush();
}
catch (Exception ex2)
{
throw new Exception(ex2.Message);
}
finally
{
// Delete the mapped drive
System.Diagnostics.Process.Start(@"C:\WINDOWS\system32\net.exe",
"use J: /delete");
}
映射驱动即可。
如果对你有用,请点赞支持,你的支持,是我不断分享的动力。
浙公网安备 33010602011771号