Wow, that was great! Now (and I guess I should have included this in my original question), can I create the "invalid" directory?
** Edit **
Split from Dynamic hyperlinks.
You can use mkdir (makedir) to make new directorys. Be advised though, that you can only create 1 dir at a time using that.For example:You can only create C:\test\test2 if c:\test allready exists. The usage goes:
Here is also a more advanced function that will loop through, and create the parent directories if they do not allready exist: - Public Function MakeDir(ByVal strPath As String) As Boolean
-
'creates a directory independent of whether the parent directory exists
-
'Code by TheSmileyOne
-
'Version 0.1
-
'Date 2010-05-19
-
-
'Known issues
-
'No error handling for cases such as network drives, with restricted permissions to create folders.
-
'No input validation
-
-
-
On Error GoTo err_Handler
-
-
'Check if rightmost char is a \
-
If Right(strPath, 1) = "\" Then
-
'Strip it
-
strPath = Left(strPath, Len(strPath) - 1)
-
End If
-
-
'Check if each individual directory exists, and if not, create it
-
Dim strSplitPath() As String
-
ReDim strSplitPath(UBound(Split(strPath, "\")))
-
strSplitPath = Split(strPath, "\")
-
Dim intI As Integer
-
Dim strCombined As String
-
-
For intI = 0 To UBound(strSplitPath)
-
If intI <> 0 Then strCombined = strCombined & "\"
-
-
strCombined = strCombined & strSplitPath(intI)
-
If Dir(strCombined, vbDirectory) = "" Then
-
MkDir strCombined
-
End If
-
Next
-
-
'Succes
-
MakeDir = True
-
Exit Function
-
MakeDir = False
-
MsgBox "Error " & Err.Number & " occured." & vbNewLine & Err.Description
-
-
End Function
6 3055
You can use mkdir (makedir) to make new directorys. Be advised though, that you can only create 1 dir at a time using that.For example:You can only create C:\test\test2 if c:\test allready exists. The usage goes:
Here is also a more advanced function that will loop through, and create the parent directories if they do not allready exist: - Public Function MakeDir(ByVal strPath As String) As Boolean
-
'creates a directory independent of whether the parent directory exists
-
'Code by TheSmileyOne
-
'Version 0.1
-
'Date 2010-05-19
-
-
'Known issues
-
'No error handling for cases such as network drives, with restricted permissions to create folders.
-
'No input validation
-
-
-
On Error GoTo err_Handler
-
-
'Check if rightmost char is a \
-
If Right(strPath, 1) = "\" Then
-
'Strip it
-
strPath = Left(strPath, Len(strPath) - 1)
-
End If
-
-
'Check if each individual directory exists, and if not, create it
-
Dim strSplitPath() As String
-
ReDim strSplitPath(UBound(Split(strPath, "\")))
-
strSplitPath = Split(strPath, "\")
-
Dim intI As Integer
-
Dim strCombined As String
-
-
For intI = 0 To UBound(strSplitPath)
-
If intI <> 0 Then strCombined = strCombined & "\"
-
-
strCombined = strCombined & strSplitPath(intI)
-
If Dir(strCombined, vbDirectory) = "" Then
-
MkDir strCombined
-
End If
-
Next
-
-
'Succes
-
MakeDir = True
-
Exit Function
-
MakeDir = False
-
MsgBox "Error " & Err.Number & " occured." & vbNewLine & Err.Description
-
-
End Function
@TheSmileyOne
Smiley, this is wonderful! (In my code, I left in ALL the comment lines, including your authorship!) Now, I really do wish I'd asked this as a separate question so that I could mark this as "best" for this issue--thanks again!
Don't worry about the Best Answer thing. This is my hobby, sorting small VBA challenges to me, is like I guess/imagine Sudoko is for other people.
NeoPa 32,556
Expert Mod 16PB
ADezii, being ADezii, asked if I would change the Best Answer (generous to a fault that boy) of the original thread. As this would not have been a best answer matching the question I could not do so (even at his request), but I was able to set it for this subsequent question as long as I split it into a separate thread (and I was happy to).
@NeoPa
I am so grateful to the contributors of this site--without you, this task would have taken so much longer and been so much more painful (not that I'm finished with it even yet!). But I am also so please to have found a community of such generosity and professionalism. It's been a long time since I've had the pleasure to bask in that kind of glow. I only hope that one day I'll be able to contribute something meaningful to a discussion.
Thanks again.
NeoPa 32,556
Expert Mod 16PB
Don't underestimate your beautifully expressed thanks Sue.
I know from my own experience how the boys will feel after working on this for you.
You take care, and come back and visit any time you fancy.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ken Fine |
last post by:
I want my application to maintain a directory tree based on months and
years, e.g.:
2004
January
file
file
file
February
file
|
by: Christian Pické |
last post by:
Hi,
I tried following code, but I get an execption "URI formats not supported"
Directory.CreateDirectory(@http://www.test.com/shop/images);
The path is not located on my own computers, but...
|
by: Paul Bromley |
last post by:
How can I create a directory within a shared ntwork directory??
sServerName - is the Server name
"\Docs" - is the shared directory
"\Others" - is the directory to create.
The following...
|
by: tomek |
last post by:
hi
i'm desperate... i'm trying this for 2 days now... so if anyone can help -
please.
i have upload form in which users can choose TYPE of file they are uploading
(graphic/text/music) - and...
|
by: AmitGujrathi |
last post by:
Hi all,,,
can anybody pls tell me how to create directory on web server using C#.Net windows application
thanks in Advance
Amit
|
by: Robert |
last post by:
Greetings
New to Visual Studio 2008.
Always us VB6.0 SP5.
I am trying to copy files from A to B.
I select a directory, and copy files. Works ok, but it does not create the
directory first.
...
|
by: kathy30 |
last post by:
I'm storing files in SQL and retrieving them when needed to the user's
C: Drive
This is accessed on our Intranet site, the problem is the create
directory and saving files happens on the Server...
|
by: coolestavi007 |
last post by:
Hi,
I have to create directories on the FTP server. I have tried directory.exists but it doesnt work.Any other way to create directory on the server.Please help me.
|
by: printline |
last post by:
Hello all
I have a php script that uploads a file from a form into a directory. The directory is automatically created through the script.
But the upload file is not put in to the directory,...
|
by: Frinavale |
last post by:
I am not the greatest system administrator and I am having some problems with my current setup which has crippled my ability to continue my current Joomla project that I'm working on.
I cannot...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |