dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language:
Expertise: Beginner
Aug 6, 1997

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Create Multiple Levels of Directories

If your users have the option to type a directory where they want files installed, they may type a directory that doesn't exist or a directory that is several levels below another directory.

This procedure checks to see if the directory exists and creates it if it doesn't. No matter how long the request, it will create any and all directories. This procedure allows users to create long directory names in VB4, but truncates each directory to 8.3 characters in VB3. The only requirements are that sDrive be passed as "<drive>:" (i.e. "C:") and that sDir be formatted as "\<directory>\" (i.e. "\Dir1\Dir2\"). Add your own error handling to make sure these elements exist properly.

Here is an example of creating a directory several levels deep and using a long directory name:

 
Sub CreateLongDir(sDrive As String, _
        sDir As String)
        Dim sBuild As String

        While InStr(2, sDir, "\") > 1
                sBuild = sBuild & Left$(sDir, _
                        InStr(2, sDir, "\") - 1)
                sDir = Mid$(sDir, InStr(2, _
                        sDir, "\"))
                If Dir$(sDrive & sBuild, 16) = _
                        "" Then
                        MkDir sDrive & sBuild
                End If
        Wend
End Sub

Sub Test()
        Call CreateLongDir("C:", _
                "\Test\TestDir\Long Directory _
                Name\")
End Sub



Jeffrey Renton
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date