title: ASP SaveToDisk method takes an incredible amount of time
body: <p>This is a method in ASP Classic that saves a file to disk. It takes a very long time but I'm not sure why. Normally, I wouldn't mind so much, but the files it handles are pretty large so need this needs to faster than 100kB a second save. Seriously slow. (old legacy system, band aid fix till it gets replaced...)</p>
  
  <pre><code>Public Sub SaveToDisk(sPath)
          Dim oFS, oFile
          Dim nIndex
  
          If sPath = "" Or FileName = "" Then Exit Sub
  
          If Mid(sPath, Len(sPath)) &lt;&gt; "\" Then sPath = sPath &amp; "\"  '"
  
          Set oFS = Server.CreateObject("Scripting.FileSystemObject")
          If Not oFS.FolderExists(sPath) Then Exit Sub
  
          Set oFile = oFS.CreateTextFile(sPath &amp; FileName, True)
  
          For nIndex = 1 to LenB(FileData)
              oFile.Write Chr(AscB(MidB(FileData,nIndex,1)))
          Next
  
          oFile.Close
      End Sub
  </code></pre>
  
  <p>I'm asking because there are plenty of WTF's in this code so I'm fighting those fires while getting some help on these ones.</p>