Code: Alles auswählen
;-TOP
; Comment: GetUserDirectoryEx
; Author : mk-soft
; Version: v1.01
; Created: 013.09.2018
; Updated: 10.09.2018
; Link :
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
#PS$ = "\"
CompilerElse
#PS$ = "/"
CompilerEndIf
Procedure.s GetUserDirectoryEx(DirectoryType, Path.s = "")
Protected result.s, dir.s, part.s, cnt
dir = GetUserDirectory(DirectoryType)
If Right(dir, 1) <> #PS$
dir + #PS$
EndIf
result = dir + path
If Not FileSize(result) = -2
result = dir
Repeat
cnt + 1
part = StringField(path, cnt, #PS$)
If Not Bool(part)
Break
EndIf
result + part + #PS$
If Not FileSize(result) = -2
If Not CreateDirectory(result)
Debug "Error: GetUserDirectoryEx(" + result + ")"
ProcedureReturn ""
EndIf
EndIf
ForEver
EndIf
If Right(result, 1) <> #PS$
result + #PS$
EndIf
ProcedureReturn result
EndProcedure
CompilerIf #PB_Compiler_IsMainFile
Define dir.s = GetUserDirectoryEx(#PB_Directory_ProgramData, "purebasic")
;Define dir.s = GetUserDirectoryEx(#PB_Directory_ProgramData, "myprogram\v1.01\data")
If OpenWindow(0, 0, 0, 400, 200, "ExplorerListGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ExplorerListGadget(0, 10, 10, 380, 180, dir, #PB_Explorer_MultiSelect)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
CompilerEndIf