Skip to content

Get_Current_Directory

See Also: Direct_Input, Get_Drive_Directory, RunProgram, Set_Directory

Purpose

To return the full path of the user's current folder, including the drive letter.

Syntax

Get_Current_Directory to {variable}

What It Does

Get_Current_Directory returns the current working folder in {variable}. The current folder is generally the [psProgramPath](../VdfClassRef/WebAndWindows/cWorkspace-Property-psProgramPath.md) value in the current workspace, but it can be changed. Normally, it is the "Start In" folder of a program shortcut (menu or shortcut file). If no "start in" location is specified in the shortcut, it will be the Windows system folder (usually C:\windows\system32). It can also be the folder where the .exe is started from (using Windows Explorer).

Example

The example below demonstrates how the current folder name is fetched, changed to the root folder of drive C, and then queried again.

Procedure CurrentFolder
    String sFolder
    // Retrieve the current folder.
    Get_Current_Directory to sFolder
    Send Info_Box sFolder "current folder"

    // Set to the root folder of drive C
    Set_Directory "C:\"

    // Now, get the new current folder.
    Get_Current_Directory to sFolder
    Send Info_Box sFolder "current folder"
End_Procedure

Send CurrentFolder

Notes

  • Caution: Unexpected behavior can result from mixing sequential I/O code that uses channels with code that does not, since sequential I/O code that does not use explicit channel numbers will use the default channel or the last channel explicitly specified. We recommend always explicitly using channel numbers.