title: How to Open a file in ASP
body: <p>I don't know how to open a file in ASP.  Here is my code which is not working.</p>
  
  <pre><code>&lt;%
      Dim vid_file
      vid_file = Request.ServerVariables("APPL_PHYSICAL_PATH")&amp; "cannon\pay\vid.dat"
      Dim vkey_file
      vkey_file = Request.ServerVariables("APPL_PHYSICAL_PATH")&amp; "cannon\pay\vkey.dat"
  
      dim fp1,f
      set fp1 = Server.CreateObject("Scripting.FileSystemObject")
      set f=fp1.OpenTextFile(Server.MapPath("vid_file"),8,true)
      f.WriteLine("This text will be added to the end of file")
      f.Close
  
      set f=Nothing
      set fp1=Nothing
  
      'Single Variable Declarations
      dim fp2,f2
      set fp2 = Server.CreateObject("Scripting.FileSystemObject")
  
      'fExists=FileSysObj.FileExists(vid_file)
      set f2=fp2.OpenTextFile(Server.MapPath("vkey_file"),8,true)
      'set TextStreamObj = fp2.OpenTextFile(vkey_file,1,true) 
      'TextStreamObj.WriteLine("This text will be added to the end of file")
      f2.WriteLine("This text will be added to the end of file")
      f2.Close
  
      set f2=Nothing
      set fp2=Nothing
  %&gt;
  </code></pre>