title: "Type Mismatch" Error with FileSystemObject.GetFile
body: <p>This script creates a text file with a randomly generated name. I want its attribute to be Hidden System, so I applied it with <code>File.Attributes</code>.</p>
  
  <p>Anyway, while running this script, text file gets created, but when it comes to applying its attributes, it throws the following error:</p>
  
  <blockquote>
    <p>Type Mismatch: 'GetFile' (Line: 7)</p>
  </blockquote>
  
  <p>Here is the code:</p>
  
  <pre><code>Dim FSO, TList, WshShell
  
  Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
  Set WshShell = WScript.CreateObject("WScript.Shell")
  
  Set TList = FSO.GetFolder(WshShell.ExpandEnvironmentStrings("%LOCALAPPDATA%") + "/Temp").CreateTextFile(FSO.GetTempName)
  FSO.GetFile(TList).Attributes = 22
  </code></pre>
  
  <p>I can't think what is causing the problem because <code>TList</code> is set using the Function <code>CreateTextFile</code>. As I think, the function <code>CreateTextFile</code> does not return <code>Scripting.File</code>, it might be <code>TextStream</code> or something. Am I correct?</p>
  
  <p>What is causing this error here?</p>