Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
|
prog:lazarus:cas:files:filenames [29/08/2019 17:53] thierry [Tests] |
prog:lazarus:cas:files:filenames [15/05/2021 15:52] (Version actuelle) thierry [Exemple] |
||
|---|---|---|---|
| Ligne 12: | Ligne 12: | ||
| vFN:=ChangeFileExt(vFN,'.ini');</code> | vFN:=ChangeFileExt(vFN,'.ini');</code> | ||
| [[https://www.freepascal.org/docs-html/rtl/sysutils/changefileext.html|ChangeFileExt]] | [[https://www.freepascal.org/docs-html/rtl/sysutils/changefileext.html|ChangeFileExt]] | ||
| + | |||
| + | ===== Répértoire ===== | ||
| + | ExtractFileDir et ExtractFilePath | ||
| + | |||
| + | ExtractFilePath contient le \ final, contrairement a ExtractFileDir. | ||
| + | |||
| + | <code delphi> | ||
| + | // le fichier MarkerList.json sera dans le méme repertoire que l'application | ||
| + | vFilename := ExtractFilePath(Application.ExeName) + 'MarkerList.json'; | ||
| + | vSL := TStringList.Create; | ||
| + | try | ||
| + | vSL.Text := GetAsJSON; | ||
| + | vSL.SaveToFile(vFilename); | ||
| + | finally | ||
| + | vSL.Free; | ||
| + | end; | ||
| + | |||
| + | </code> | ||
| + | |||
| + | ===== Exemple ===== | ||
| + | <code delphi> | ||
| + | Uses sysutils; | ||
| + | |||
| + | Procedure Testit(F : String); | ||
| + | |||
| + | begin | ||
| + | Writeln ('FileName : ',F); | ||
| + | Writeln ('Has Name : ',ExtractFileName(F)); | ||
| + | Writeln ('Has Path : ',ExtractFilePath(F)); | ||
| + | Writeln ('Has Extension : ',ExtractFileExt(F)); | ||
| + | Writeln ('Has Directory : ',ExtractFileDir(F)); | ||
| + | Writeln ('Has Drive : ',ExtractFileDrive(F)); | ||
| + | end; | ||
| + | |||
| + | Begin | ||
| + | Testit (Paramstr(0)); | ||
| + | Testit ('/usr/local/bin/mysqld'); | ||
| + | Testit ('c:\pp\bin\win32\ppc386.exe'); | ||
| + | Testit ('/pp/bin/win32/ppc386.exe'); | ||
| + | End. | ||
| + | </code> | ||
| + | ===== Chercher ===== | ||
| + | ==== Chercher un executable ==== | ||
| + | * Rechercher un executable dans une suite de dossiers :\\ [[https://www.freepascal.org/docs-html/rtl/sysutils/exesearch.html]] | ||
| + | |||
| + | |||
| + | ===== Sources et Ressources ===== | ||
| + | * [[https://www.freepascal.org/docs-html/rtl/sysutils/extractfiledir.html]] | ||
| + | * [[https://www.freepascal.org/docs-html/rtl/sysutils/getcurrentdir.html]] | ||
| + | |||
| + | |||