|
-
Feb 5th, 2000, 01:35 AM
#1
Thread Starter
New Member
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
-
Feb 5th, 2000, 02:39 AM
#2
Just use the MkDir statement:
MkDir "C:\MyNewFolderName"
Good luck!
------------------
Joacim Andersson
[email protected]
[email protected]
www.YellowBlazer.com
-
Feb 5th, 2000, 03:42 AM
#3
Thread Starter
New Member
-
Feb 5th, 2000, 04:58 AM
#4
Hyperactive Member
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
[email protected]
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|