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"); }

  

映射驱动即可。

posted on 2022-12-08 16:32  芝麻的西瓜  阅读(214)  评论(0编辑  收藏  举报