Code Comments
Programming Forum and web based access to our favorite programming groups.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?
Post Follow-up to this messagePrivate Declare Function MakeSureDirectoryPathExists Lib "imagehlp.dll" (ByVal lpPath As String) As Long MakeSureDirectoryPathExists "D:\AAA\BBB\CCC\DDD"
Post Follow-up to this messageAfraid 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? >
Post Follow-up to this messageI'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?
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.