Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. ...
  2. MemoryStream streamReader;
  3. ...
  4. myClass.mapdrive();
  5. byte[] buffer = new byte[4096];
  6.  
  7. using (FileStream streamWriter = File.Create(@"\myserverthesharemyfile.txt"))
  8. {
  9. StreamUtils.Copy(streamReader, streamWriter, buffer); //<-- Point of Exception (Access Denied)
  10. }
  11.  
  12. public class myclass
  13. {
  14. public static void mapdrive()
  15. {
  16. System.Diagnostics.Process p = new System.Diagnostics.Process();
  17. p.StartInfo.UseShellExecute = false;
  18. p.StartInfo.CreateNoWindow = true;
  19. p.StartInfo.RedirectStandardError = true;
  20. p.StartInfo.RedirectStandardOutput = true;
  21. p.StartInfo.FileName = "net.exe";
  22. p.StartInfo.Arguments = String.Format(
  23. "net use %1 %2 /USER:%3",
  24. @"\myservertheshare",
  25. "passme",
  26. @"\myservermyuser"
  27. );
  28. p.Start();
  29. p.WaitForExit();
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement