

If Result Loop through until NextDirectoryEntry (0) becomes zero - indicating that there are no more entries. Result ExamineDirectory (0, Folder, '.') If this is ok, begin enumeration of entries. If there are some entries in the list, show the results in the debug window.Īnd resorts it into ascending order ( #PB_Sort_Ascending), of the Name field of the structure ClearList ( Files ()) Open the directory to enumerate its contents. SortStructuredList( Files(), #PB_Sort_Ascending, OffsetOf(FILEITEM\Name), #PB_String) Sort the list into ascending alphabetical order of file name. Line before the comment about showing the list and the So now things should begin to look a bitįinally, for now, the list isn't in any particular order, so let's The FormatDate() function takes a date in PureBasic's own numeric date format andĭisplays it in a format that we can specify. Replace the last three Debug statementsĭebug "Created = " + FormatDate("%dd/%mm/%yyyy", Files()\DateCreated)ĭebug "Accessed = " + FormatDate("%dd/%mm/%yyyy", Files()\DateAccessed)ĭebug "Modified = " + FormatDate("%dd/%mm/%yyyy", Files()\DateModified) So let's make them look a bit more familiar. Ok, firstly, the dates in the output are just numbers - this isn't very helpful, FinishDirectory(0)ĮndIf Shows the results in the debug window (if there is no entry, nothing will be displayed) ForEach Files()ĭebug "Attributes = " + StrU( Files()\Attributes)ĭebug "Created = " + StrU( Files()\DateCreated)ĭebug "Accessed = " + StrU( Files()\DateAccessed)ĭebug "Modified = " + StrU( Files()\DateModified) Files()\Name = DirectoryEntryName(0)įiles()\Attributes = DirectoryEntryAttributes(0)įiles()\DateCreated = DirectoryEntryDate(0, #PB_Date_Created)įiles()\DateAccessed = DirectoryEntryDate(0, #PB_Date_Accessed)įiles()\DateModified = DirectoryEntryDate(0, #PB_Date_Modified)ĮndIf Wend Close the directory.

And populate it with the properties of the file.

If DirectoryEntryType(0) = #PB_DirectoryEntry_File Add a new element to the list. If the directory entry is a file, not a folder. Loop through until NextDirectoryEntry(0) becomes zero - indicating that there are no more entries. If this is ok, begin enumeration of entries. Hi, Its possible to change the order for ExamineDirectory results I may want to receive by size, by date )new first or older first), etc. Result = ExamineDirectory(0, Folder, "*.*") Open the directory to enumerate all its contents. I guess it is how the file-system gives the entries by default. This is a general problem, not a personal. And there must be an opportunity, to override these protection by the programm, else, it is impossible to delete a folder under WindowsXP home.
Purebasic examinedirectory windows#
This function gets the home directory for the logged on user. As long, as the programm, which created the folder or read the directory with examine directory is not closed, the folder is protected by windows xp. Structure FILEITEMĮndStructure Now we define a new list of files using the structure previously specified and some other working variables we'll use later on. This section describes the fields of a structure or record, mostly integers in this case, but notice the string for the file name and the quad for the file size. Will come back to this example later on and make it a bit more friendly in several For now the output isn't very exciting but we User's home directory into a structured list. It's not minimalist - I'm increasing efficiency by reducing input effort.This example gathers information about the files in the logged on Does Windows perform pattern matching against both long and short names at the same time? Update: I also found that the line 'If ExamineDirectory(0, pathname, "*.htm")' matches files with. FName.s'' Size.l 0 Test.s 'C:\Documents and Settings\User' If ExamineDirectory (0, Test, '.') Repeat FileType NextDirectoryEntry () If FileType FName DirectoryEntryName () Debug FName If FName 'My Documents' Size DirectoryEntrySize () EndIf. "*.htm|*.chm", except that doesn't work or anything more flexible than just * and ? by themselves. I am trying to make a program that will get the size of a directory. Several PureBasic versions at once Migrating from an old version of PureBasic. By proper I mean something like searching for multiple extensions (e.g.
Purebasic examinedirectory how to#
Originally posted by tinman.ġ) Are the directories "." and "." really part of the filesystem under Windows? They get reported by ExamineDirectory with a pattern of "*.*", it just seemed a little weird (I thought they were just symbolic names to mean current directory and parent directory).Ģ) Anyone got a document that explains how to construct *proper* wildcards for Windows? The Win32 help file (FindFirstFile_()) and Google turned out to be useless.
