REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 18-Feb-2009 Edit History  

REBOL 3 Concepts: Tour: Files

Pending Revision

This document was written for R2 and has yet to be revised for R3.

OLD DOCS

This section is obsolete and being replaced. It is kept only as a source for new content.

In REBOL, files are easily accessed. The following table describes some of the ways to access files.

You can read a text file with:

data: read %plan.txt

You can display a text file with:

print read %plan.txt

To write a text file:

write %plan.txt data

For instance, you could write out the current time with:

write %plan.txt now

You can also easily append to the end of a file:

write/append %plan data

Binary files can be read and written with:

data: read/binary %image.jpg

write/binary %new.jpg data

To load a file as a REBOL block or value:

data: load %data.r

Saving a block or a value to a file is just as easy:

save %data.r data

To evaluate a file as a script (it needs a header to do this.):

do %script.r

You can read a file directory with:

dir: read %images/

and, you can then display the file names with:

foreach file dir [print file]

To make a new directory:

make-dir %newdir/

To find out the current directory path:

print what-dir

If you need to delete a file:

delete %oldfile.txt

You can also rename a file with:

rename %old.txt %new.txt

To get information about a file:

print size? %file.txt

print modified? %file.txt

print dir? %image


  TOC < Back Next > REBOL.com - WIP Wiki Feedback Admin