Opening and appending to a text file

Results 1 to 2 of 2

Thread: Opening and appending to a text file

  1. #1
    Join Date
    Dec 1969

    Default Opening and appending to a text file

    I keep getting a file not found error when I try to open a txt file called gbpeople.txt. The book I have uses paths like c:lala.txt but Im doing it directly off the server online so Im just putting the name of the file. This seems right but why do I keep getting the file not found? It definately exists. Heres the script from what Im trying to do.<BR>&#060;%<BR>Dim filesys, txtfile<BR>Set filesys = CreateObject("Scripting.FileSystemObject")<BR>Set txtfile = filesys.OpenTextFile("gbpeople.txt",8,0)<BR>txtfil e.WriteLine("Im writing to the text file.")<BR>txtfile.Close<BR>%&#062;<BR><BR>Im new to this and Im stumped here. Any help is greatly appreciated.

  2. #2
    Conrad Guest

    Default Try this.

    &#039 Get the current path.<BR>str_path_dir = Request.ServerVariables("SCRIPT_NAME")<BR>str_path _dir = StrReverse(str_path_dir)<BR>str_path_dir = Mid(str_path_dir, InStr(1, str_path_dir, "/"))<BR>str_path_dir = StrReverse(str_path_dir)<BR><BR>&#039 add the filename you want to create to the path.<BR>str_path_dir = str_path_dir & "filename.html"<BR>str_path_dir = Server.MapPath(str_path_dir)<BR><BR>&#039 Create the path<BR>Set obj_filesystem = Server.CreateObject("Scripting.FileSystemObject")< BR>obj_filesystem.CreateTextFile str_oldfile<BR><BR>&#039 Be a good programmer and cleanup after yourself.<BR>Set obj_filesystem = Nothing<BR><BR>Good Luck!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts