title: FileSystemObject - Reading Unicode Files
body: <p>Classic ASP, VBScript context.</p>
  
  <p>A lot of articles including <a href="http://www.microsoft.com/technet/scriptcenter/guide/sas_scr_eqco.mspx?mfr=true" rel="noreferrer">this Microsoft one</a>, say you <strong>cannot</strong> use FileSystemObject to read Unicode files.</p>
  
  <p>I encountered this issue a while back, so switched to using ADODB.Stream instead, per the ReadText example <a href="http://www.motobit.com/tips/detpg_read-write-binary-files/" rel="noreferrer">here</a>, instead of using <a href="http://msdn.microsoft.com/en-us/library/314cz14s%28VS.85%29.aspx" rel="noreferrer">FileSystemObject.OpenTextFile</a> (which does accept a final parameter indicating whether to open the file as unicode, but actually doesn't work).</p>
  
  <p>However, ADODB.Stream results in a world of pain when trying to read a file on a UNC fileshare (permissions-related issue). So, investigating this, I stumbled across the following approach which works a) with unicode files, and b) across UNC fileshares:</p>
  
  <pre><code>dim fso, file, stream
  set fso = Server.CreateObject("Scripting.FileSystemObject")
  set file = fso.GetFile("\\SomeServer\Somefile.txt")
  set stream = file.OpenAsTextStream(ForReading,-1) '-1 = unicode
  </code></pre>
  
  <p>This is using the FSO to read a unicode file without any apparent problem, so I'm confused as to all the references, including MS, saying you can't use the FSO to read unicode files. </p>
  
  <p>Has anyone else used this approach for reading unicode files? Are there any hidden gotchas I'm missing, or can you really actually read unicode files using FSO?</p>