Create a file
Contract| Return type | type.<one_of false resource.filesystem.file/> | | No input parameters. | | Water Contract<method resource.filesystem.file.create
_return_type=<type.one_of false resource.filesystem.file/>/> | |
See also: file, folder, exists, set, set_file_content_and_create_folders_as_needed
Creates an empty file at the specified path. If the file specified already
exists, create will return the file. If there is an
error creating the file, e.g., the folder specified does not exist,
create will throw an error.
Example: Create an empty file
<file "logical://user/test_file.txt" />.<create />
The set method can also be used to create a file and set its
content .
Example: Create a file with set content
<file "logical://user/test_file.txt" />.<set content="new stuff" />
Caution should be used when creating a new file using set because
the set method will overwrite the contents of an already existing
file, whereas the create method will return the contents of an
already existing file. To be safe, the exists method should be used
to determine whether a to-be-created file already exists.
It is also possible to create a new file in a path that does not yet exist
by using the set_file_content_and_create_folders_as_needed method.
Notice that the field name for this method is new_content .
Example: Create a new file with a new path
<file "logical://user/new_folder/test_file.txt" />.
<set_file_content_and_create_folders_as_needed new_content="new stuff" />
© Copyright 2007 Clear Methods, Inc.