title: Creating a Directory on a remote machine using VB.NET
body: <p>How can I create a directory on a remote server using .NET? Both servers are running Windows Server 2003. I have looked at the system.IO.directory class, and FtpWebRequest, both of which don't seem to do what I need.</p>
  
  <p>If there isn't an existing method for this, I should be able to form a VPN tunnel, map the drive, and use directory.copy, right?</p>
  
  <p><strong>Update:</strong>
  Decided to take Rockinthesixstring's advice and create a web service on the server in which I need to create the directories. I built the following ASMX file, compiled it in visual studio, and was able to successfully invoke it from the browser page that is "automagically" generated from the ASMX file</p>
  
  <pre><code>Imports System.Web.Services
  Imports System.Web.Services.Protocols
  Imports System.ComponentModel
  
      &lt;System.Web.Script.Services.ScriptService()&gt; _
      &lt;System.Web.Services.WebService(Namespace:="http://ttanet.com/")&gt; _
      &lt;System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)&gt; _
      &lt;ToolboxItem(False)&gt; _
      Public Class Service1
          Inherits System.Web.Services.WebService
          &lt;WebMethod()&gt; _
  
          'Here is where we invoke our exposed method'
          Public Sub makeDir(ByVal dirName As String)
              System.IO.Directory.CreateDirectory("C:/TransferTest/" &amp; dirName)
          End Sub
  
      End Class
  </code></pre>
  
  <p>Excellent suggestion -Thanks Rockin...</p>
  
  <p>The second half of my question is the best way to invoke it. I need to call it from a VB.NET app. I am trying to invoke it from a browser, like:</p>
  
  <pre><code>http://localhost:60870/MakeDirectory.asmx/makeDir?dirName=testingFromURL
  </code></pre>
  
  <p>But it yields:</p>
  
  <pre><code>Exception Details: System.InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/makeDir'.
  </code></pre>
  
  <p>I was planning on looping through and sending WebRequestFactory.Create(urlForGetRequest) through an iteration. Is something wrong with the way my URL is structured, Is there a better way?</p>