442
Platforms
©2000-2008 Tibbo Technology Inc.
If
fd.delete("File1.dat")<>PL_FD_STATUS_OK
Then
'some problem
End
If
If
fd.delete("File2 abc")<>PL_FD_STATUS_OK
Then
'the "abc" part will be
ignored -- everything after the space is NOT a part of the file name
'some problem
End
If
If
fd.delete(" Database/users.dat")<>PL_FD_STATUS_OK
Then
'leading
spaces will be ignored
'some problem
End
If
The file you are deleting must exist, of course, or you will get the 9-
PL_FD_STATUS_NOT_FOUND error. It is OK to delete a file which is currently
.
You can also rename a file using the
method.
Reading and Writing File Attributes
a new file. To read
existing file attributes, use the
method:
'this example ignores potential error conditions
Dim
s
As
String
...
s=fd.getattributes("File1.dat")
'get the attributes for this file
If
instr(1,s,"R",1)=0
Then
'delete the file only if there is no 'R' in the
attributes
fd.delete("File1.dat")
End
If
You can set new (change) attributes with the
method:
If
fd.setattributes("File1.dat", "D")<>PL_FD_STATUS_OK
Then
'the attribute
string will now consist of a single 'D'
'some problem
End
If
Remember that the file name and the attributes share the same 56-byte string in
the file record table of the flash disk. Therefore, the maximum length of the
attributes is limited to 56 -- length_of_the_file_name-. This "-1" accounts for the
space that separates the file name from the attributes.
Attempting to perform the fd.getattributes or fd.setattributes on a file that does
not exist will generate the 9- PL_FD_STATUS_NOT_FOUND error.
Walking Through File Directory
At times it is necessary to get the list of all files stored on the flash disk. Most
operating systems provide this feature in the form of a DIR command. The fd.
object offers two methods --
and
--
that allow you to get the names of all stored files one by one.
443
477
440
441
467
478
478
470