title: Invalid procedure call or argument in vbscript
body: <p>I am using vb script to upload a file to the server. The problem I'm having is that when I set the file to ASCII format like this...</p>
  
  <pre><code>Set oFile = oFS.CreateTextFile(sPath &amp; FileName, True, False)
  </code></pre>
  
  <p>I get an error when the sub is called that says </p>
  
  <blockquote>
    <p>Invalid procedure call or argument</p>
  </blockquote>
  
  <p>but if I set the file to unicode</p>
  
  <pre><code>Set oFile = oFS.CreateTextFile(sPath &amp; FileName, True, True)
  </code></pre>
  
  <p>it uploads successfully but will not open because of the incorrect encoding.
  The line that produces the error is this one if format is ASCII is this one</p>
  
  <pre><code>oFile.Write BinaryToString(FileData)
  </code></pre>
  
  <p>where <code>oFile</code> is the ASCII file I had created above</p>
  
  <p>Here is the source code that produces the error. It's an upload function I got off the net..</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, False)
          oFile.Write BinaryToString(FileData)
  
          oFile.Close
      End Sub
  
      Function BinaryToString(Binary)
          'Antonin Foller, http://www.motobit.com
          'Optimized version of a simple BinaryToString algorithm.
  
          Dim cl1, cl2, cl3, pl1, pl2, pl3
          Dim L
          cl1 = 1
          cl2 = 1
          cl3 = 1
          L = LenB(Binary)
  
          Do While cl1&lt;=L
              pl3 = pl3 &amp; Chr(AscB(MidB(Binary,cl1,1)))
              cl1 = cl1 + 1
              cl3 = cl3 + 1
              If cl3&gt;300 Then
                  pl2 = pl2 &amp; pl3
                  pl3 = ""
                  cl3 = 1
                  cl2 = cl2 + 1
                  If cl2&gt;200 Then
                      pl1 = pl1 &amp; pl2
                      pl2 = ""
                      cl2 = 1
                  End If
              End If
          Loop
          BinaryToString = pl1 &amp; pl2 &amp; pl3
      End Function
  </code></pre>
  
  <p>Could it be configurations on the server? If this makes any sense please help..</p>