Results 1 to 7 of 7

Thread: IO.File.Exists?

  1. #1

    Thread Starter
    Addicted Member Dmyze's Avatar
    Join Date
    Mar 2002
    Location
    Seattle
    Posts
    160

    IO.File.Exists?

    I have a directory set up that people can put images of themselves in. My program checks to see if they have put a default photo in, and if they have not it displays a generic image. No matter what I put into the IO.Fle.Exists Line It always returns false. I have made the folder in question a Public Shared folder with everyone having read access, and the ASP Account has full access to it.

    VB Code:
    1. If IO.File.Exists("\\server\Photos\Emp\" & oDis.Manager.ExchangeName & "\" & "default.jpg") Then
    2.       imgPic.ImageUrl = "http://server/Photos/Emp/" & oDis.Manager.ExchangeName & "/default.jpg"
    3.     Else
    4.       imgPic.ImageUrl = "http://server/Photos/Emp/NA/default.jpg"
    5.     End If
    -Daryl
    "Two More Rolls of Duct tape, and the world is mine!"
    VB.NET Guru

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    might be because oDis.Manager.ExchangeName isnt returning what you think it is, or it is returning nothing. Debug that.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Addicted Member Dmyze's Avatar
    Join Date
    Mar 2002
    Location
    Seattle
    Posts
    160
    I've walked though the routine, the command is correct.
    -Daryl
    "Two More Rolls of Duct tape, and the world is mine!"
    VB.NET Guru

  4. #4

    Thread Starter
    Addicted Member Dmyze's Avatar
    Join Date
    Mar 2002
    Location
    Seattle
    Posts
    160
    Suddenly an apple strikes me on the head.

    I just realized that the Photos and the web site are on the same server so I just changed the command to:


    VB Code:
    1. If IO.File.Exists("D:\wwwroot\Photos\Emp\" & oDis.Manager.ExchangeName & "\" & "default.jpg") Then
    2.       imgPic.ImageUrl = "http://server/Photos/Emp/" & oDis.Manager.ExchangeName & "/default.jpg"
    3.     Else
    4.       imgPic.ImageUrl = "http://server/Photos/Emp/NA/default.jpg"
    5.     End If


    Thanks for your help!
    -Daryl
    "Two More Rolls of Duct tape, and the world is mine!"
    VB.NET Guru

  5. #5
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    You can probably use something like Server.MapPath

    I haven't used it myself yet, so I can't give you the exact syntax, but it will free you from hard coding paths.

  6. #6

    Thread Starter
    Addicted Member Dmyze's Avatar
    Join Date
    Mar 2002
    Location
    Seattle
    Posts
    160
    I did try using Server.MapPath but was unsuccessful
    -Daryl
    "Two More Rolls of Duct tape, and the world is mine!"
    VB.NET Guru

  7. #7
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    Server.MapPath("myPicture.jpg") will return C:\inetpub\wwwroot\myPicture.jpg for example (if wwwroot is the folder)
    \m/\m/

Posting Permissions

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



Click Here to Expand Forum to Full Width