title: How to open connection to local network path protected by password in smart way? (Whith C#)
body: <p>I developing program witch have to write some data in file whom are stored in network computer witch are protected by password. 
  Now I'm doing this way - open connection with cmd then write data. </p>
  
  <pre><code>    static bool ConnectToSrv()
      {
          String myUser = "domain.local\\user";
          String myPass = "pwd";
          String cmdString = "net use \\\\otherPC\\folder\\ /user:" + myUser + " " + myPass;
          try
          {
              ManagementClass processClass = new ManagementClass("Win32_Process");
              object[] methodArgs = { cmdString, null, null, 0 };
              object result = processClass.InvokeMethod("Create", methodArgs);
              return true;
          }
          catch (System.Exception error)
          {
              return false;
          }
  
      }
  
  public void writeDate(string data){ }
  </code></pre>
  
  <p>I believe there must by better way. I mean the .NET way.
  Does anybody know how to do it? :)<br>
  Thanks    </p>