Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. checking whether a file exist

checking whether a file exist

Scheduled Pinned Locked Moved ASP.NET
sysadminhelp
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Meax
    wrote on last edited by
    #1

    This doesn't work. Eventhough the image is there in the directory i get "Does not exist" If CheckFileExists("http://localhost/MySite/images/Mouse.jpg") Then Response.Write("Exist") Else Response.Write("Does not exist") End If Howerver this works. in my page i get the msg "Exist" If CheckFileExists("C:\Inetpub\wwwroot\MySite\images\Mouse.jpg") Then Response.Write("Exist") Else Response.Write("Does not exist") End If This is the function i am using. Call this function in my page load event Function CheckFileExists(ByVal sFileName) Dim FileSystemObject FileSystemObject = Server.CreateObject("Scripting.FileSystemObject") If (FileSystemObject.FileExists(sFileName)) Then CheckFileExists = True Else CheckFileExists = False End If FileSystemObject = Nothing End Function So, wondering why it doesn't work when i use "http://localhost/MySite/images/Mouse.jpg" can you guys help me with this thanks

    C 1 Reply Last reply
    0
    • M Meax

      This doesn't work. Eventhough the image is there in the directory i get "Does not exist" If CheckFileExists("http://localhost/MySite/images/Mouse.jpg") Then Response.Write("Exist") Else Response.Write("Does not exist") End If Howerver this works. in my page i get the msg "Exist" If CheckFileExists("C:\Inetpub\wwwroot\MySite\images\Mouse.jpg") Then Response.Write("Exist") Else Response.Write("Does not exist") End If This is the function i am using. Call this function in my page load event Function CheckFileExists(ByVal sFileName) Dim FileSystemObject FileSystemObject = Server.CreateObject("Scripting.FileSystemObject") If (FileSystemObject.FileExists(sFileName)) Then CheckFileExists = True Else CheckFileExists = False End If FileSystemObject = Nothing End Function So, wondering why it doesn't work when i use "http://localhost/MySite/images/Mouse.jpg" can you guys help me with this thanks

      C Offline
      C Offline
      CoolAmir
      wrote on last edited by
      #2

      The method accepts a path not a URL. Use HttpServerUtility.Mappath to convert a relative path to physical path. -- modified at 6:01 Saturday 5th November, 2005

      M 1 Reply Last reply
      0
      • C CoolAmir

        The method accepts a path not a URL. Use HttpServerUtility.Mappath to convert a relative path to physical path. -- modified at 6:01 Saturday 5th November, 2005

        M Offline
        M Offline
        Meax
        wrote on last edited by
        #3

        thank you for replying

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups