Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I searched lots of methods and i did it my own way. You have to open a connection between two machine via command prompt NET USE command and after finishing your work clear the connection with command prompt NET USE "myconnection" /delete.</p> <p>You must use Command Prompt process from code behind like this: </p> <pre><code>var savePath = @"\\servername\foldername\myfilename.jpg"; var filePath = @"C:\\temp\myfileTosave.jpg"; </code></pre> <p>Usage is simple:</p> <pre><code>SaveACopyfileToServer(filePath, savePath); </code></pre> <p>Here is functions: </p> <pre><code>using System.IO using System.Diagnostics; public static void SaveACopyfileToServer(string filePath, string savePath) { var directory = Path.GetDirectoryName(savePath).Trim(); var username = "loginusername"; var password = "loginpassword"; var filenameToSave = Path.GetFileName(savePath); if (!directory.EndsWith("\\")) filenameToSave = "\\" + filenameToSave; var command = "NET USE " + directory + " /delete"; ExecuteCommand(command, 5000); command = "NET USE " + directory + " /user:" + username + " " + password; ExecuteCommand(command, 5000); command = " copy \"" + filePath + "\" \"" + directory + filenameToSave + "\""; ExecuteCommand(command, 5000); command = "NET USE " + directory + " /delete"; ExecuteCommand(command, 5000); } </code></pre> <p>And also ExecuteCommand function is: </p> <pre><code>public static int ExecuteCommand(string command, int timeout) { var processInfo = new ProcessStartInfo("cmd.exe", "/C " + command) { CreateNoWindow = true, UseShellExecute = false, WorkingDirectory = "C:\\", }; var process = Process.Start(processInfo); process.WaitForExit(timeout); var exitCode = process.ExitCode; process.Close(); return exitCode; } </code></pre> <p>This functions worked very fast and stable for me. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload