Autor Beitrag
McFarlane
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68

WIN XP Prof.
Delphi 2005 PE, Turbo Delphi 2006, PHP (Eclipse)
BeitragVerfasst: So 08.10.06 12:11 
Tach,
ich möchte nach einer Pfadangabe überprüfen, ob dort ein Ordner "maps" existiert.
Ich hab zwar in der Hilfe was in der Art gefunden, aber nicht kapiert... :oops:
Könnte mir mal bitte jemand nen übersichtlichen Quelltext geben?
Danke, McFarlane
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: So 08.10.06 12:15 
ausblenden Delphi-Quelltext
1:
2:
3:
if directoryexists(D:\ein\Pfad) then
  Mcfarlane.freu
else McFarlane.traurigschau;


Hab zwar jetzt kein Delphi da aber ich glaub so müssts gehen!

mfg el

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
hui1991
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 433

Windows XP, WIndows Vista
Turbo Delphi Explorer| Delphi, PHP,Blitzbasic
BeitragVerfasst: So 08.10.06 12:25 
Hallo,

du kennst wohl nicht dsdt.info

Da kann man in Tipps und Tricks das hier finden:
dsdt.info/tipps/?id=154


Mit Hilfe der Funktion DirectoryExists kann man überprüfen, ob ein Verzeichnis existiert. Die Funktion erwartet als Parameter den Pfad zum Verzeichnis
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
uses SysUtils;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if DirectoryExists('C:\Programme') then
    Showmessage('Das Verzeichnis existiert');
end;

Sollte sich die o.g. Funktion in Ihrer Delphi-Version nicht in der unit SysUtils befinden, binden Sie die Unit FileCtrl ein. In neueren Delphi-Versionen ist die Funktion DirectoryExists nur noch aus Gründen der Abwärtskompatiblität in der Unit FileCtrl enthalten.
McFarlane Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68

WIN XP Prof.
Delphi 2005 PE, Turbo Delphi 2006, PHP (Eclipse)
BeitragVerfasst: So 08.10.06 13:01 
OK, vielen Dank.
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: So 08.10.06 13:21 
Wenn du später UniCode verwenden willst, musst du aber über die WinAPI gehen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
var
  DirEx: Cardinal;

    DirEx:=GetFileAttributesW(PWideChar(MyFileName)); //DirectoryExists
    if (DirEx<>DWord(-1)) and (FILE_ATTRIBUTE_DIRECTORY and DirEx=FILE_ATTRIBUTE_DIRECTORY) then
    begin
      //hier dein Code
    end


Für die Ansivariante einfach statt nem W nen A ranhängen, oder es weglassen (also GetFileAttributes) ;).