File Access Component

Results 1 to 2 of 2

Thread: File Access Component

  1. #1
    Ryan Hartos Guest

    Default File Access Component

    How do you detect if a file is present in a virtual directory. The problem is regarding a shopping cart. Some products have image files while others do not. I want to be able to detect if the image file is present (named via the product ID number) and if so display it and visa versa.

  2. #2
    Ian S Guest

    Default RE: File Access Component

    This is possible.<BR>I had to set up a test to prove it to my self so here&#039s the code<BR>I used below:<BR>(I explained the procedure I used in the comments)<BR>&#060;%<BR>&#039first we create the filesystem object<BR>set fso = Server.CreateObject("Scripting.FileSystemObject")< BR><BR>&#039the following obtains the actual path using the virtual path:<BR>dim strFilePath<BR>strFilePath = Server.MapPath("/testing/filesystem")<BR><BR>&#039 this appends the "\" and the file name to the actual path<BR>&#039 we obtained above:<BR>strFilePath = strFilePath & "\" & "hello.txt"<BR><BR>&#039 uses .FileExists() of filesystem object<BR>&#039 method to check for file:<BR> if fso.FileExists(strFilePath) then<BR> response.write("file exists")<BR> else<BR> response.write("file doesnt&#039t exist")<BR> end if<BR><BR>&#039 close the object<BR>Set fso = nothing<BR><BR>%&#062;<BR><BR><BR><BR>I hope this helps some. If you need more specifics or help<BR>let me know. :-)

Posting Permissions

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