If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Write to File ASP

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-29-04, 10:35
Maximus2004 Maximus2004 is offline
Registered User
 
Join Date: Jun 2004
Posts: 8
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)
Else
Set objTextS = objFS.CreateTextFile("c:\Max.txt", False, False)
End if
objTextS.WriteLine "This was written at " & Now & "."
objTextS.Close

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
Loop
objTextS.Close

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.
Reply With Quote
  #2 (permalink)  
Old 07-29-04, 19:10
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
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....
Reply With Quote
  #3 (permalink)  
Old 07-30-04, 12:14
Seppuku Seppuku is offline
Useless...
 
Join Date: Jul 2003
Location: SoCal
Posts: 721
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On