;
; ------------------------------------------------------------
;
; PureBasic - FileSystem example file
;
; (c) 2001 - Fantaisie Software
;
; ------------------------------------------------------------
;
; NOTE: This file doesn't compile with the demo version !
;
;
; As the following operations modify the disk structure physically
; it has been commented. Anyway, it totally safe to use them, just verify than
; the used filename aren't actually used...
;
; MessageRequester("Info","C:\AutoExec.bat file size: "+Str(FileSize("C:\AutoExec.bat")),0)
; CreateDirectory("C:\TestDir_PB")
; CopyFile("C:\AutoExec.bat", "C:\AutoExec.pb")
; RenameFile("C:\AutoExec.pb", "C:\AutoExec2.pb")
; DeleteFile("C:\AutoExec2.pb")
If OpenWindow(0, 100, 200, 290, 200, "PureBasic - FileSystem Example")
If CreateGadgetList(WindowID(0))
StringGadget (0, 10, 10, 202, 24, "")
SetGadgetText (0, "C:\")
ButtonGadget (1, 220, 10, 60 , 24, "List")
ListViewGadget(2, 10, 40, 270, 150)
EndIf
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_Gadget
If EventGadget() = 1 ; Read
ClearGadgetItemList(2) ; Clear all the items found in the ListView
If ExamineDirectory(0, GetGadgetText(0), "*.*")
While NextDirectoryEntry(0)
FileName$ = DirectoryEntryName(0)
If DirectoryEntryType(0) = 2 ; Directory type
FileName$ = "(DIR) "+FileName$
EndIf
AddGadgetItem(2, -1, FileName$)
Wend
Else
MessageRequester("Error","Can't examine this directory: "+GetGadgetText(0),0)
EndIf
EndIf
EndIf
Until EventID = #PB_Event_CloseWindow
EndIf
End