Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2004

    Unanswered: Write to File ASP

    I have listed my code and also the ouput. Output tells me "file was written" when I go to c: drive I do not see this file created.
    Pls Help. Thank you!

    <% @ LANGUAGE = VBScript %>
    <% Option Explicit %>
    Const ForReading = 1, ForWriting = 2, ForAppending = 8
    Const TristatUseDefault = -2 ' Opens the file using the system default
    Const TristateTrue = -1 'Opens the file as Unicode
    Const TristateFalse = 0 'Opens the file as ASCII

    Dim ObjFS, objTextS, strLine

    Set objFS=Server.CreateObject ("Scripting.FileSystemObject")
    If objFS.FileExists("c:\Max.txt") = True Then
    Set objTextS = objFS.OpenTextFile("c:\Max.txt", ForAppending, False, TristateFalse)
    Set objTextS = objFS.CreateTextFile("c:\Max.txt", False, False)
    End if
    objTextS.WriteLine "This was written at " & Now & "."

    Set objTextS = objFS.OpenTextFile("c:\Max.txt", ForReading,TristateFalse)

    Response.Write "The Content of the File: <br><br>" & VbCrlf
    Do While objTextS.AtEndOfStream <> True
    strLine = objTextS.ReadLine
    strLine = Server.HTMLEncode(strLine)
    Response.Write strLine & "<Br>" & VbCrlf

    Set objTextS = Nothing
    Set objFS = Nothing


    output from LocalHost------

    The Content of the File:

    This was written at 7/29/2004 10:07:54 AM.

  2. #2
    Join Date
    Nov 2003
    Christchurch, New Zealand
    well from looking at your code and the output from the page it definately looks like the file is being written (after all you are reading it out).

    it could be something as simple as refreshing the file listing, or perhaps you don't have permissions to see the file....

  3. #3
    Join Date
    Jul 2003
    If you have the line "On Error Resume Next" somewhere above this code, you may not be seeing the true error that is being generated..
    That which does not kill me postpones the inevitable.

Posting Permissions

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