Steve Schapel
steve at datamanagementsolutions.biz
Fri Jun 24 15:22:46 CDT 2011
Ok, thanks a lot, Stuart. Well, I have learnt something here. But I must also say that I don't think I will be changing my usual practice here, in order to prevent a problem that I can't imagine would ever arise. Regards Steve -----Original Message----- From: Stuart McLachlan Sent: Friday, June 24, 2011 6:02 PM To: Steve Schapel Subject: Re: [AccessD] Does a directory exist? Yes, because it will throw an error if C:\Major is a file. -- Stuart On 24 Jun 2011 at 17:32, Steve Schapel wrote: > Thanks for that, Stuart, I wasn't aware of the need to be careful > there with the possibility of files and folders of the same name. > > Any reason, then, not to include the trailing slash for a directory? > E.g. Len(Dir("C:\Major\", vbDirectory)) > > Regards > Steve > > -----Original Message----- > From: Stuart McLachlan > Sent: Friday, June 24, 2011 4:48 PM > To: Access Developers discussion and problem solving > Subject: Re: [AccessD] Does a directory exist? > > My first try didn't cover all contingencies. > > This one should work: > > Function IsDir(pathname As String) As Boolean > If Len(Dir(pathname, vbDirectory + vbHidden + vbSystem + vbReadOnly)) > Then > If GetAttr(pathname) And vbDirectory = vbDirectory Then > IsDir = True > End If > End If > End Function > > -- > Stuart > > On 24 Jun 2011 at 14:37, Stuart McLachlan wrote: > > > Here ya go: > > > > Function IsDir(pathname As String) As Boolean > > If Len(Dir(pathname, vbDirectory)) Then > > If GetAttr(pathname) = vbDirectory Then > > IsDir = True > > End If > > End If > > End Function > > > > > > On 24 Jun 2011 at 14:30, Stuart McLachlan wrote: > > > > > That doesn't work. If there is a file called C:\Major, it still > > > returns 8. > > > > > > <quote> > > > vbDirectory 16 Specifies directories or folders in addition to > > > files with no attributes </Quote> > > > > > > I'll try to dig out an IsDir() and post it. > > > > > > -- > > > Stuart > > > > > > On 24 Jun 2011 at 16:16, Steve Schapel wrote: > > > > > > > Arthur > > > > > > > > Len(Dir("C:\Major", vbDirectory)) > > > > > > > > And to the follow up question, I am pretty sure you have to do > > > > it in 2 steps. > > > > > > > > Regards > > > > Steve > > > > > > > > -----Original Message----- > > > > From: Arthur Fuller > > > > Sent: Friday, June 24, 2011 4:02 PM > > > > To: Access Developers discussion and problem solving > > > > Subject: [AccessD] Does a directory exist? > > > > > > > > I've been playing around with the Dir() function but I can't > > > > figure out how to determine whether a directory exists, so I can > > > > create it if it doesn't. Followup question: can I create a > > > > directory called "C:\major\minor" if "C:\major" doesn't exist, > > > > or do I have to create "C:\major" first and then create > > > > "C:\major\minor"? > > > > > > > > TIA, > > > > Arthur > > > > > > > > -- > > > > AccessD mailing list > > > > AccessD at databaseadvisors.com > > > > http://databaseadvisors.com/mailman/listinfo/accessd > > > > Website: http://www.databaseadvisors.com > > > > > > > > > > > > > > > > -- > > > AccessD mailing list > > > AccessD at databaseadvisors.com > > > http://databaseadvisors.com/mailman/listinfo/accessd > > > Website: http://www.databaseadvisors.com > > > > > > > > > > > -- > > AccessD mailing list > > AccessD at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/accessd > > Website: http://www.databaseadvisors.com > > > > > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com >