Results 1 to 4 of 4

Thread: Need To Create New Folder

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 1999
    Location
    Wichita, KS, US
    Posts
    10

    Post

    I am working on a program, and when it loads, I would like it to create a folder, to store files that will be used in the program, but I don't know how to do this. And upon searching for questions similar to this, I noticed that all of them utilize the FileSystemObject procedure, and I do not have that capability. So my question is: Is there anyway to create a new folder without using FileSystemObject?

    Thanks in advance

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Post

    Just use the MkDir statement:

    MkDir "C:\MyNewFolderName"

    Good luck!

    ------------------
    Joacim Andersson
    joacim@programmer.net
    joacim@yellowblazer.com
    www.YellowBlazer.com



  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 1999
    Location
    Wichita, KS, US
    Posts
    10

    Post

    Alright! Thanks a lot.

  4. #4
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485

    Post

    Chrisjk was kind enough to post this for me recently. It helped me a bunch:

    posted 01-29-2000 06:56 PM
    --------------------------------------------------------------------------------
    I have dealt with a fair few computers, and all of them have had the hard disk at C:\. You don't get much choice, the BIOS assigns drive letters for bootable devices such as floppy and Hard disk, then Windows assigns left-over drives (such as a CD-ROM) with subsequent drive letters. You can change letters Windows assigns though.
    So unless someone has a really obscure BIOS, everything should be cool.

    With regard MkDir (finally ), you need to do this

    MkDir "C:\Whatever"

    Word of warning - MkDir will only make new directories in ones that already exist, e.g If you had a folder called "Whatever" on your hard disk, and you tried this

    MkDir "C:\Whatever\Wow\Cool"

    it would fail because "Wow" does not exist. However, this would work:

    MkDir "C:\Whatever\Wow"

    because "Whatever" does exist, and it would make "Wow" in "Whatever". Understand?

    To get around this you have to write your own function that will make any directory, anywhere on your hard disk, whether previous ones exist or not.

    To do this, copy the following to the Declarations section of a module:

    ---------------

    Public Sub MakeDirectory(Path As String)

    Dim strCheck As String
    Dim strPath As String
    Dim intPosition As Double
    Dim intCheckPosition As Double

    If Right(Path, 1) <> "\" Then
    strPath = Path & "\"
    Else
    strPath = Path
    End If

    intPosition = 4
    intCheckPosition = 1

    Do While intCheckPosition <= Len(strPath)
    Do While Right(strCheck, 1) <> "\"
    strCheck = Left(strPath, intPosition)
    intPosition = intPosition + 1
    Loop

    strCheck = Left(strCheck, Len(strCheck) - 1)
    intPosition = intPosition + 1

    If Dir(strCheck, vbDirectory) = "" Then
    MkDir strCheck
    End If
    intCheckPosition = intCheckPosition + 1
    Loop

    End Sub

    ---------------

    Now, if you want to make a directory anywhere, call the function using this code:

    ---------------

    MakeDirectory "C:\Whatever\Wow\Cool"

    ---------------

    Hope that helps

    Good luck

    ------------------
    - Chris
    chris.kilhams@btinternet.com
    If it ain't broke - don't fix it



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