Page 1 of 1

Posted: Thu Jan 31, 2002 5:46 pm
by BackupUser
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. ?

Posted: Thu Jan 31, 2002 6:04 pm
by BackupUser
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.

Posted: Thu Jan 31, 2002 6:21 pm
by BackupUser
Restored from previous forum. Originally posted by Paul.

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

Posted: Thu Jan 31, 2002 9:56 pm
by BackupUser
Restored from previous forum. Originally posted by Paul.

Actually thats a good idea TronDoc...

The snippet.zip file is now a single zip with each snippet in its own folder. Just remember to unzip using the "Use Folders" (-d) option, or everything will unzip into your root folder.

Posted: Fri Feb 01, 2002 11:07 am
by BackupUser
Restored from previous forum. Originally posted by Ralf.

Thanks.
works great.