Restored from previous forum. Originally posted by Ralf.
How can put the contains of a directory in to a file.
In DOS i do it like this : DIR C:\TEST\*.* > C:\TESTOUT\CONTENTS.TXT
IN QBASIC like THIS : SHELL "DIR C:\TEST\*.* > ....."
But now i want to do that in PUREBASIC without any DOS command. ?
Read directory contents into a file
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Paul.
Look in the documentation under FileSystem.
There is an example there called FileSyetem.pb that reads in a directory and the files it contains.
Just modify the code to read the directory file names into an array and then save them back disk into a new file.
Look in the documentation under FileSystem.
There is an example there called FileSyetem.pb that reads in a directory and the files it contains.
Just modify the code to read the directory file names into an array and then save them back disk into a new file.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Paul.
Or skip the array and do this:
Or skip the array and do this:
Code: Select all
If ExamineDirectory(0, "c:\test\", "*.*")
If CreateFile(0,"c:\testout\contents.txt")
Repeat
type=NextDirectoryEntry()
If type=1
WriteStringN(DirectoryEntryName() )
EndIf
Until type=0
CloseFile(0)
EndIf
EndIf
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm