File is a GeneXus data type that allows you to manage system files. It makes it easier to develop applications that need to execute actions that affect system files.
The File data type enables system file management. It can be used for typical operations such as copying, moving, renaming and deleting files. You can also use File data type to get file attributes such as modification, date, time and size.
Source |
Assign a path to the file. The source cannot be read, use GetAbsoluteName(*) instead. |
Separator |
Returns the name separator character depending on the OS. |
ErrCode |
Returns the result of the last operation. |
ErrDescription |
Returns the result description of the last operation. |
Copy |
Copies the specified file to a new file. |
Delete |
Deletes the specified file. |
Exists |
Determines whether the specified file exists. |
GetName |
Returns the name of the specified file. |
(*)GetAbsoluteName |
Returns the full path name of the specified file. |
GetPath |
Returns the path of the parent directory. |
Rename |
Renames the specified file. |
GetLastModified |
Returns the date and time the specified file was last modified. |
GetLength |
Gets the size of the specified file. |
Open |
see more details |
Close |
see more details |
Copies the file specified in source to a new location. If the target file already exists, it will be overridden.
New filename (Character)
&file.copy("c:\empcopiedFile.txt")
Deletes the file specified in source.
&file.delete()
Checks whether the file specified in source exists
Boolean
If &file.exists()
msg("The file exists!")
Else
msg("The file does not exist!")
EndIf
Returns the name of the file specified in source.
Character
&file.Source="c:\myFile.txt"
Msg(&file.GetName()) // screen shows: myFile.txt
Return the absolute name of the file specified in source.
Character
&file.Source="c:\empmyFile.txt"
Msg(&file.GetAbsoluteName()) // screen shows: c:\empmyFile.txt
Returns the path of the parent directory.
Character
&parentDir = &file.getPath()
Renames the file specified in source. It can also be used to move the file, changing its current path.
New name of the file (Character)
&file.Rename("d:\empnewFileName.txt")
Returns the date and time the file specified in source was last modified.
DateTime
&dateTime = &file.GetLastModified()
Returns the size (in bytes) of the file specified in source.
Numeric
&size = &file.GetLength()
0 |
Operation completed successfully. |
1 |
Invalid file instance - if source property was not set. |
2 |
File does not exist. |
3 |
File already exists. |
100 |
Security error. |
-1 |
Undefined error. |
File data type: Text file handling