Returns the name of the current directory.
function GetCurrentDir: string;
AnsiString GetCurrentDir();
SysUtils
GetCurrentDir returns the fully qualified name of the current directory.
Delphi Examples:
{ This example shows how to change and display the current directory through text. This example requires that a drive combo box, a file list box, and a directory list box are on a form. Add this code as the OnChange event handler for the drive combo box and the OnChange event handler for the directory list box. When the user changes the drive using the combo box, the directory list box and file list box will update to reflect the new drive and the current directory on that drive. When the user double clicks on a directory in the file list box will update to reflect the new directory. } procedure TForm1.Button1Click(Sender: TObject); begin System.ChDir(Edit1.Text); if IOResult <> 0 then MessageDlg('Cannot find directory', mtWarning, [mbOk], 0); Edit2.Text := GetCurrentDir; FileListBox1.Directory := GetCurrentDir; DirectoryListBox1.Directory := GetCurrentDir; end; procedure TForm1.DirectoryListBox1Change(Sender: TObject); begin FileListBox1.Directory := DirectoryListBox1.Directory; Edit2.Text := GetCurrentDir; end; procedure TForm1.DriveComboBox1Change(Sender: TObject); begin DirectoryListBox1.Drive := DriveComboBox1.Drive; FileListBox1.Drive := DriveComboBox1.Drive; FileListBox1.Directory := DirectoryListBox1.Directory; Edit2.Text := GetCurrentDir; end;
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|