Gambas Documentation
Application Repository
Code Snippets
Compilation & Installation
Controls pictures
Deprecated components
Developer Documentation
Development Environment Documentation
Error Messages
Gambas Playground
How To's
Language Index
Language Overviews
Arithmetical Functions
Arithmetic Operators
Array Declaration
Assignment Operators
Binary Data Representation
Bits Manipulation Functions
Character Test Functions
Comparison methods
Complex numbers
Constant Declaration
Constant Expression
Conversion Functions
Datatype Functions
Date & Time Functions
Enumeration declaration
Error Management
Event Loop
Event Management
Events declaration
External Function Management
File & Directory Functions
File & Directory Paths
File mode syntax
Floating Point Numbers
Formatting functions
Gambas Object Model
Global Special Event Handlers
Integer numbers
Intrinsic Functions
Language Constants
Localization and Translation Functions
Local Variable Declaration
Logarithms & Exponentials Functions
Logical Operators
Loop Control Structures
Method Declaration
Miscellaneous Control Structures
Miscellaneous Functions
Native Arrays
Native Container Classes
Object & Class Management
Operator Evaluation Order
Predefined Constants
Process Management
Property Declaration
Random Numbers Functions
Special Methods
Stream & Input/Output functions
String Functions
String Operators
Structure declaration
Test Control Structures & Functions
Trigonometric Functions
User-defined formats
Using reserved keywords as identifiers
Variable Declaration
Last Changes
Search the wiki
To Do
Wiki License
Wiki Manual

File & Directory Paths

There are two kinds of file or directory paths in Gambas:

  • Absolute paths.

  • Relative paths.

Absolute Paths

Absolute paths start with a / or a ~ character. They are interpreted the same way as in a shell.

If a path starts with a ~ character followed by a / character, then the ~ character is replaced by the user home directory.

Otherwise, if a path starts with a ~ not followed by a /, then the characters up to the next slash or up to the path end must be a system user name. Then they are replaced by the home directory of that user.


Gambas path Actual path
~/Desktop /home/benoit/Desktop
~root/Desktop /root/Desktop

You must never use absolute paths pointing at your project directory, because these paths do not exist anymore when you make an executable. You must use relative paths instead.

Relative Paths

Relative paths are paths that do not start with a / character or a ~ character.

They refer to files or directories located inside the current project executable or current component executable.

Relative paths do not refer to files located in the current working directory, as there is no concept of current working directory in Gambas!

As files located inside the current project are actually archived inside one executable file, they are read-only.

While running your project in the IDE, project files can be modified by using absolute paths. But do not do that! As soon as your project is run as an executable, these absolute paths do not exist anymore.

When compiling an executable, hidden files and files in any hidden directories (i.e. whose names begin with a dot) are not included.

Only the hidden folder called .public is included. This is the "Public" folder of the IDE project tree.

So files needed by the executable must be in either a non hidden folder or in the .public folder.

If you need to access a file located in the main project from a component, it is possible! You must start your relative path by the ../ sequence.

Manipulating paths

The File class provides many static functions that allows to manipulate file paths.