;
; Create a file at a given path location creating sub-directories if necessary
;
Procedure DoCreateFile(n.l, FileName.s)
PathPart.s = ""
FilePart.s = GetFilePart(FileName)
If GetPathPart(FileName) <> ""
i = 1
Repeat
Node.s = StringField(FileName, i, "\")
If Node = FilePart
Break
EndIf
PathPart + Node + "\"
If FileSize(PathPart) = -2
Else
CreateDirectory(PathPart)
EndIf
i + 1
Until Node = ""
EndIf
ProcedureReturn CreateFile(n, FileName)
EndProcedure
;
; Test
;
If DoCreateFile(0, "toto\dudule\machin.txt")
CloseFile(0)
EndIf
If DoCreateFile(0, "machin.txt")
CloseFile(0)
EndIf
End
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
The MakeSureDirectoryPathExists function creates all the directories in the specified DirPath.
BOOL MakeSureDirectoryPathExists(
IN LPSTR DirPath
);
Parameters
DirPath
A pointer to an ASCII string that contains a valid path name.
Return Values
If the function succeeds, the return value is TRUE.
If the function fails, then the return value is FALSE. To retrieve extended error information, call GetLastError.
Remarks
The DirPath is parsed and each directory, beginning at the root, is created, if it does not already exist. If only some of the directories are created, the function will return FALSE.
I need to check to see if the folder exists - e.g. IsFolder(folderpath$)
fweil appears to be creating a file with the 'folderpath$' and seeing if it is successful. If you create a 'dummy' file in the folder then I suppose you would have to 'Delete' the dummy file.
Any ideas for a IsFolder() checking that is not API?