Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

MkDir with blanks
I played a little bit around to get a function which creates a complete
directory tree (subsequent directories) and not only one additional level,
so that I could make a call like 'MakeDir D:\AAA\BBB\CCC\DDD' which calls
subsequent MkDirs internally. It works fine as long as there are no embedded
blanks.

Now testing with some portions of the pathname having embedded blanks I
found that adding chr$(34) at the beginning and the end of the pathname
variable the MkDir command sometimes works and sometimes not: MkDir chr$(34)
& pathname & chr$(34).

I found that if there is no embedded blank chr$(34) will cause an error.
This is no big problem because it's easy to distingusih between pathnames
with or without blanks and to run MkDir without Chr$(34) if no blanks given.

But when there are one or more blanks I found no system till now - chr$(34)
will not always help. Sometimes the MkDir command worked as expected and
sometimes not. Did anyone else encounter this problem?



Report this thread to moderator Post Follow-up to this message
Old Post
Bruno Köller
05-29-05 08:55 PM


Re: MkDir with blanks
Private Declare Function MakeSureDirectoryPathExists Lib "imagehlp.dll"
(ByVal lpPath As String) As Long

MakeSureDirectoryPathExists "D:\AAA\BBB\CCC\DDD"



Report this thread to moderator Post Follow-up to this message
Old Post
Benedikt Hübschen
05-29-05 08:55 PM


Re: MkDir with blanks
Afraid I didn't bother testing with blanks, but check whether either of the
approaches Randy Birch outlines in
http://vbnet.mvps.org/code/file/nested.htm work for you.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"Bruno Köller" <mydevicenull@onlinehome.de> wrote in message
news:d7cfir$rk4$1@online.de...
>I played a little bit around to get a function which creates a complete
>directory tree (subsequent directories) and not only one additional level,
>so that I could make a call like 'MakeDir D:\AAA\BBB\CCC\DDD' which calls
>subsequent MkDirs internally. It works fine as long as there are no
>embedded blanks.
>
> Now testing with some portions of the pathname having embedded blanks I
> found that adding chr$(34) at the beginning and the end of the pathname
> variable the MkDir command sometimes works and sometimes not: MkDir
> chr$(34) & pathname & chr$(34).
>
> I found that if there is no embedded blank chr$(34) will cause an error.
> This is no big problem because it's easy to distingusih between pathnames
> with or without blanks and to run MkDir without Chr$(34) if no blanks
> given.
>
> But when there are one or more blanks I found no system till now -
> chr$(34) will not always help. Sometimes the MkDir command worked as
> expected and sometimes not. Did anyone else encounter this problem?
>



Report this thread to moderator Post Follow-up to this message
Old Post
Douglas J. Steele
05-29-05 08:55 PM


Re: MkDir with blanks
I'd suggest using a function like the following to put things in
quotes:

Public Const vbQuote As String = """"

Public Function QQ(sToQuote As String, Optional sQC As String = vbQuote) As 
String
QQ = sQC & sToQuote & sQC
End Function

That way it's impossible to forget a quote character. The only problem
then is if the path already has quote characters embedded...

'...
If Left$(sPath, 1) <> vbQuote Then
sPath = QQ(sPath)
End If
MkDir sPath

The route you take is going to depend upon if you're explicitly
controlling the path or are allowing a user to type in a path.

Also, there are some characters that are not spaces that look
like spaces, if you're using cut and paste operations to do
what you're doing. That's something that might need to taken
in consideration if you're copying and pasting from HTML.

Hope that helps.

--
Jim Carlock
Please post replies to newsgroup.

"Bruno Köller" <mydevicenull@onlinehome.de> wrote:
I played a little bit around to get a function which creates a complete
directory tree (subsequent directories) and not only one additional level,
so that I could make a call like 'MakeDir D:\AAA\BBB\CCC\DDD' which calls
subsequent MkDirs internally. It works fine as long as there are no embedded
blanks.

Now testing with some portions of the pathname having embedded blanks I
found that adding chr$(34) at the beginning and the end of the pathname
variable the MkDir command sometimes works and sometimes not: MkDir chr$(34)
& pathname & chr$(34).

I found that if there is no embedded blank chr$(34) will cause an error.
This is no big problem because it's easy to distingusih between pathnames
with or without blanks and to run MkDir without Chr$(34) if no blanks given.

But when there are one or more blanks I found no system till now - chr$(34)
will not always help. Sometimes the MkDir command worked as expected and
sometimes not. Did anyone else encounter this problem?



Report this thread to moderator Post Follow-up to this message
Old Post
Jim Carlock
05-29-05 08:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Visual Basic archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:35 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.