當前位置:編程學習大全網 - 編程軟體 - delphi中如何opendialog1.FileName;只能打開文件,如何打開目錄獲得目錄路徑

delphi中如何opendialog1.FileName;只能打開文件,如何打開目錄獲得目錄路徑

在uses中加入 FileCtrl;

function SelectDirectory(const Caption: string; const Root: WideString; out Directory: string): Boolean;

SelectDirectory彈出對話框讓用戶選擇目錄,不改變目錄的鍵值,在linux和windows中格式有所不同,

caption標題是長字符串

const Root指定瀏覽的根目錄

out Directory返回所選目錄

ShowHidden標識所選目錄是否顯示隱藏子目錄

例:

var

Save_Cursor: TCursor;

s : string;

begin

Save_Cursor := Screen.Cursor;

Screen.Cursor := crHourglass;

try

if SelectDirectory('請選擇文件夾:','',s) then

begin

edtFileName.Text:=s;

end;

finally

Screen.Cursor := Save_Cursor;

end;

end;

  • 上一篇:美術考級的證書到底能不能在中考的時候加分
  • 下一篇:車載音樂怎麽調播放模式?
  • copyright 2024編程學習大全網