Programmieren - alles kontrollieren 4.939 Themen, 20.672 Beiträge

FindFirstFile

PaoloP / 11 Antworten / Flachansicht Nickles

Hallo,

Ich habe ein mir unerklärliches Verhalten der Funktion
FindFirstFile in Visual C++ 6.

Das Problem tritt dann auf wenn ich es direkt auf ein Laufwerk anwende also genau gesagt mit manchen Laufwerken klappt es und mit anderen nicht, auf meinem Rechner befinden sich 3 Festplatten C:,D: und F:

WIN32_FIND_DATA ffdata;
HANDLE hFindFile;
hFindFile = FindFirstFile( "c:",&ffdata );

Der Aufruf funktioniert so wunderbar bei Laufwerk C: und auch auf meinem Laufwerk F: aber nicht auf D: und ich habe keine Ahnung wieso.
Natürlich habe ich es mit Backslash "d:\\\\" probiert aber dann klappt das bei keinem Laufwerk mehr. Achja es befinden sich sowohl Ordner aus auch Dateien auf den Laufwerken, ich habe natürlich versucht gleiche Testbedingungen herzustellen um den Fehler zu finden was mich aber nicht wesentlich weitergebracht hat. Hat hier vielleicht jemand eine Idee oder kennt das Problem ?

Gruss Fein
Paul



Jedes mal wenn jemand "Cloud" sagt, verliert ein Engel seine Flügel.
bei Antwort benachrichtigen
FindFirstFile d-oli
mr.escape PaoloP „Es funktioniert ja wenn ich d: unterordner angebe aber nicht wenn ich d: angebe....“
Optionen

Noch was dazu:
The FindFirstFile function opens a search handle and returns information about the first file whose name matches the specified pattern. After the search handle has been established, use the FindNextFile function to search for other files that match the same pattern. When the search handle is no longer needed, close it by using the FindClose function.

In rare cases, file attribute information on NTFS file systems may not be current at the time you call this function. To obtain the current NTFS file attributes, call GetFileInformationByHandle.

This function searches for files by name only; it cannot be used for attribute-based searches.

You cannot use root directories as the lpFileName input string for FindFirstFile, with or without a trailing backslash. To examine files in a root directory, use something like "C:\*" and step through the directory with FindNextFile. To get the attributes of a root directory, use GetFileAttributes. Prepending the string "\\?\" does not allow access to the root directory.

Similarly, on network shares, you can use an lpFileName of the form "\\server\service\*" but you cannot use an lpFileName that points to the share itself, such as "\\server\service".

To examine any directory other than a root directory, use an appropriate path to that directory, with no trailing backslash. For example, an argument of "C:\windows" will return information about the directory "C:\windows", not about any directory or file in "C:\windows". An attempt to open a search with a trailing backslash will always fail.


mr.escape

"The man who trades freedom for security does not deserve nor will he ever receive either." - Benjamin Franklin"Wer seine Freiheit aufgibt, um Sicherheit zu erreichen, wird beides verlieren." - Georg Christoph Lichtenberg
bei Antwort benachrichtigen