Filesystemobject question

Results 1 to 2 of 2

Thread: Filesystemobject question

  1. #1
    Join Date
    Dec 1969

    Default Filesystemobject question

    I have an asp page part of which contains the following code:<BR><BR>Dim objFSO, strURL<BR>Set objFSO = Server.CreateObject("Scripting.FileSystemObject")< BR>Dim objTextStream<BR>const strFileName = "upload/test.txt"<BR>const fsoForReading = 1<BR><BR>If objFSO.FileExists("upload/test.txt") then<BR> &#039;The file exists, so open it and output its contents<BR> Set objTextStream = objFSO.OpenTextFile(strFileName, fsoForReading)<BR> Response.Write "" & objTextStream.ReadAll & ""<BR> objTextStream.Close<BR> Set objTextStream = Nothing<BR>Else<BR> &#039;The file did not exist<BR> Response.Write strFileName & " was not found."<BR>End If<BR><BR>Set objFSO = Nothing<BR><BR>The file, test.txt is located in a folder called "Upload" on my web server. When I open the page, the file is not found.<BR>My web server support informed me that the path is correct.<BR>I tried putting the text file on my local machine and I still get the same message. <BR>Do I have an error in the code?<BR><BR>Thanks

  2. #2
    Join Date
    Dec 1969

    Default RE: Filesystemobject question

    The path you pass it must be a full physical path. If you only have a virtual path, use Server.MapPath() to convert it.<BR><BR>Craig.

Posting Permissions

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