Theo Posted August 11, 2006 Posted August 11, 2006 (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 August 11, 2006 by Theo Quote
Administrators PlausiblyDamp Posted August 11, 2006 Administrators Posted August 11, 2006 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") Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Theo Posted August 11, 2006 Author Posted August 11, 2006 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 Quote
Administrators PlausiblyDamp Posted August 11, 2006 Administrators Posted August 11, 2006 Does the ASPNET account have permissions to the Z:\afbeeldingen folder? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Theo Posted August 11, 2006 Author Posted August 11, 2006 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! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.