Directory is a new GeneXus data type that allows the management of system directories. It makes easier the development of applications that need to execute actions over system directories and files.
Directory data type allows managing system directories. Use Directory data type for typical operations such as creating, copying, moving, renaming and deleting directories. You can also use the Directory data type to get the directory attributes such as modification date time and size.
Source |
Selects the directory in the specified path |
ErrCode |
Returns the result of the last operation |
ErrDescription |
Returns the result description of the last operation |
Create |
Creates a new directory in the specified source |
Delete |
Deletes the specified directory. |
Exists |
Determines whether the specified directory exists. |
GetName |
Returns the name of the specified directory |
GetAbsoluteName |
Returns the full path name of the specified directory |
Rename |
Renames the specified directory |
GetFiles |
Returns the files in the specified directory |
GetDirectories |
Returns the directories in the specified directory |
Create
Creates a new directory
Parameters
Directory Name (character)
Example:
&directory.Source="c:\temp"
&directory.create()
Delete
Deletes the directory specified in source.
Example:
Exists
Checks whether the directory specified in source exists
Returned Values
Boolean
Example:
if & directory.exists()
msg("The directory exists!")
else
msg("The directory does not exist!")
endif
GetName
Return the directory of the file specified in source.
Returned Values
Character
Example:
& directory.Source="c:\temp "
Msg(&directory.GetName()) // screen shows: temp
GetAbsoluteName
Return the absolute name of the directory specified in source.
Returned Values
Character
Example:
&file.Source="c:\temp
Msg(&directory.GetAbsoluteName()) // screen shows: c: emp
Rename
Renames the directory specified in source. It can be also used to move the directory changing its current path.
Parameters
New name of the directory (Character)
Example:
&file.Rename("d:\temp2 ")
GetFiles
Returns the names of files in the specified directory.
Parameters:
Filter (Character)
Example:
en Java for &auxFile in &directory.GetFiles('txt') en .NET for &auxFile in &directory.GetFiles('*.txt')
//do something //do something
endfor endfor
where &auxFile is defined as a File variable.
GetDirectories
Returns the names of directories in the specified directory.
Example:
for &auxDir in &directory.GetDirectories()
//do something
endfor
where &auxDir is defined as a Directory variable.
0 |
Operation completed successfully |
1 |
Invalid directory instante - if source property was not set |
2 |
Directory does not exist |
3 |
Directory already exists |
4 |
Directory not empty |
100 |
Security error |
-1 |
Undefined error |
You can download an example from:
http://www.gxopen.com/gxopen/servlet/hproject?426
The example shows how File and Directory data types can be used to manage system files and directories.
From .NET Build 382 (9.0 RC) and Java Build 50 (9.0 RC) the "exists" method returns a boolean instead of a numeric value.
Languages: Java, .NET, .NET Mobile, Visual Basic
Objects: Procedures, Work Panels, Web Panels, Transactions