Results 1 to 3 of 3

Thread: ASP - Checking a file exists? (Virtual Directory / Share)

  1. #1
    LWA
    LWA is offline
    Senior Member
    Join Date
    Jul 2003
    Location
    London
    Posts
    2,171
    Thanks
    134
    Thanked
    57 times in 41 posts

    Question ASP - Checking a file exists? (Virtual Directory / Share)

    Guys and gals,
    I need a bit of help if you wouldn't mind. The following code can be used to see whether a file exists:


    Dim FileSystemObject
    Set FileSystemObject = Server.CreateObject("Scripting.FileSystemObject")

    If (FileSystemObject.FileExists("C:\test\test.txt")) Then
    response.write "File Exists"
    Else
    response.write "File does not exist"
    End If


    However this does not work if the file is on a virtual directory or on a share.

    Anyone have any ideas how to work around this?

    Thanks for your help,
    Leon

  2. #2
    Ex-MSFT Paul Adams's Avatar
    Join Date
    Jul 2003
    Location
    %systemroot%
    Posts
    1,926
    Thanks
    29
    Thanked
    77 times in 59 posts
    • Paul Adams's system
      • Motherboard:
      • Asus Maximus VIII
      • CPU:
      • Intel Core i7-6700K
      • Memory:
      • 16GB
      • Storage:
      • 2x250GB SSD / 500GB SSD / 2TB HDD
      • Graphics card(s):
      • nVidia GeForce GTX1080
      • Operating System:
      • Windows 10 x64 Pro
      • Monitor(s):
      • Philips 40" 4K
      • Internet:
      • 500Mbps fiber
    For virtual folders, I think you need to use the Server.MapPath() function so the physical path is returned:
    i.e.
    objFSO.FileExists(Server.MapPath(strVirtualPath))

    Microsoft KB


    IIS uses the local IUSR_xxx account to authenticate, which other machines won't be able to recognise so you might have to make a shared resource allow anonymous access to work with files on shares.
    ~ I have CDO. It's like OCD except the letters are in alphabetical order, as they should be. ~
    PC: Win10 x64 | Asus Maximus VIII | Core i7-6700K | 16GB DDR3 | 2x250GB SSD | 500GB SSD | 2TB SATA-300 | GeForce GTX1080
    Camera: Canon 60D | Sigma 10-20/4.0-5.6 | Canon 100/2.8 | Tamron 18-270/3.5-6.3

  3. #3
    LWA
    LWA is offline
    Senior Member
    Join Date
    Jul 2003
    Location
    London
    Posts
    2,171
    Thanks
    134
    Thanked
    57 times in 41 posts
    Paul,
    Thanks for the reply.

    I read through the article and I don't get any errors displayed, I just get the "File does not exist" printed to the screen. I am also using the full path to file e.g. http://asp_server/virtual_dir_name/temp.jpg

    Just for reference the virtual directory I am using is being used elsewhere in the page to display a picture. But before attempting to display the picture I need to check it exists.

    I currently can display the picture but the message still says the picture file does not exist.

    The virtual directory I am using looks at a share on a different server.
    Last edited by LWA; 15-12-2005 at 01:12 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 63
    Last Post: 14-11-2011, 09:17 AM
  2. Need help on my maxtor harddrives
    By arthurleung in forum PC Hardware and Components
    Replies: 10
    Last Post: 12-06-2007, 09:40 PM
  3. Nero vision express saying:'Burn process failed'
    By johnnr892 in forum Help! Quick Relief From Tech Headaches
    Replies: 15
    Last Post: 11-12-2005, 11:43 PM
  4. Replies: 12
    Last Post: 04-11-2005, 12:18 PM

Posting Permissions

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