Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

Hi all,

 

Im trying to use the Dir function to determine wether a certain image excists or not. But the variable strDir is always empty, even when an image does excist. (see code below).

 

   Public Function getIMG(ByVal pItem As String) As String
       Dim strDir As String

       strDir = Dir("Z:\images\" & pItem & ".jpg")

       Return strDir
   End Function

 

- The parameter pItem is the name of the image without the extension.

- All the images have NO attributes

Edited by Theo
Posted
The Dir function is really a legacy VB function (and it wasn't that good then) - Try using the classes under System.IO.

 

e.g.

If System.IO.File.Exists("z:\images\" & pItem & ".jpg")

 

 

I've adapted my function like you can see below, but without any result. It seems like ASP.NET isn't able to see the existing images.

 

   Public Function getIMG(ByVal pItem As String) As String
       Dim strDir As String

       If System.IO.File.Exists("Z:\afbeeldingen\" & pItem & ".jpg") = True Then
           strDir = "Z:\afbeeldingen\" & pItem & ".jpg"
       Else
           strDir = "blank"
       End If

       Return strDir
   End Function

Posted
Does the ASPNET account have permissions to the Z:\afbeeldingen folder?

 

That seemed to be the problem. I copied the images to the local drive and now it works fine. So it must be the permissions indeed.

 

Thanks!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...