Autor Beitrag
yndaso
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 108



BeitragVerfasst: Mi 11.03.09 10:53 
Hallo!

Wie kann ich den Pfad einer bestimmten Datei ermitteln. In meiner Anwendung möchte ich die Festplatte nach einer exe Datei durchsuchen.
Ich habe mir schon die Klassen

System.IO.File
System.IO.Directory
System.IO.Path

auf MSDN mal angeschaut, aber ich habe nix passendes gefunden.

Wäre für einen Hilfreichen tipp sehr dankbar

Gruß


Moderiert von user profile iconKha: Topic aus WinForms verschoben am Mi 11.03.2009 um 18:12
yndaso Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 108



BeitragVerfasst: Mi 11.03.09 11:51 
Hat sich erledigt.

Das es schließlich doch so easy ist...

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
                //Verzeichnis angeben wo gesucht werden soll
                DirectoryInfo di = new DirectoryInfo("C:\\Program Files");

                //jedes File im Ordner angeben
                FileInfo[] nPath= di.GetFiles("test.exe", SearchOption.AllDirectories);

                //Anzahl (Index) der Files ermitteln
                Int32 nArrayLength = nPath.GetLength(0);
JüTho
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2021
Erhaltene Danke: 6

Win XP Prof
C# 2.0 (#D für NET 2.0, dazu Firebird); früher Delphi 5 und Delphi 2005 Pro
BeitragVerfasst: Mi 11.03.09 12:25 
Da es sich um ein 1-dimensionales Array handelt, geht auch nPath.Length. Jürgen