You'll have to uncomment the CreateDirectory line for it to actually work, but run as is in Debugger to see how it would work in action. Of course, IF the drive exists it will fail to create the root directory. To be expected:
Procedure Makepath(Sample$)
Sample$ = Trim(Sample$, "\")
Path$ = ""
For D = 1 To CountString(Sample$, "\") + 1
Path$ + StringField(Sample$, D, "\") + "\"
If FileSize(Path$) = -1
Debug Path$
; CreateDirectory(Path$)
Else
Debug Path$+" already exists"
EndIf
Next D
EndProcedure
;Examples with and without trailing \
Makepath("D:\Eat\At\Joes\Bar\And\Grill\")
Delay(3000)
Makepath("D:\Eat\At\Joes\Bar\And\Grill")
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Nothing is faster, more stable, or easier to maintain than code that doesn’t exist.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Nothing is faster, more stable, or easier to maintain than code that doesn’t exist.
I'm, guessing change backslash to forward slash for Linux or MAC in my procedure to get it to work there. Cannot test here.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Nothing is faster, more stable, or easier to maintain than code that doesn’t exist.
Randy Walker wrote: Tue Mar 10, 2026 9:08 am
I'm, guessing change backslash to forward slash for Linux or MAC in my procedure to get it to work there. Cannot test here.
Fun Fact: It's on the Deprecated APi Section since more than 10 years now.
SHCreateDirectory is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions.
Just because it worked doesn't mean it works. PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
Not on Mac: you cannot create a dir if there's a file with the same name (at least not on Finder… don't wanna risk to try with PB and nuke my filesystem )