How to find out if the path points to the actual file?

I have a function as follows:

DWORD stats = GetFileAttributesA(path);
return (stats != INVALID_FILE_ATTRIBUTES) && !(stats & FILE_ATTRIBUTE_DIRECTORY) ? 1 : 0;

The problem is that the SQL Connection line is: "Driver = {SQL Server Native Client 10.0}; server = localhost; database = NorthWindDB; Trusted_Connection = yes;" somehow really. It returns 32 (statistics 32 when this input is specified), which is the value of FILE_ATTRIBUTE_ARCHIVE. I cannot filter this because other legit files also return this value.

How to determine if a value indicates a file or connection string?

UPDATE: PathFileExists not working either

0
source share
5 answers

, , , : system("dir \"path_to_check\"") ( :) . ().

+1

FindFirstFile FindFirstFileEx?

, ( , ).

lpFileName, INVALID_HANDLE_VALUE.

, , , .

+1
+1

:

#include <windows.h>
#include <iostream>
using namespace std;

int main() {

    DWORD stats = GetFileAttributesA( "Driver={SQL Server Native Client 10.0};server=localhost;database=NorthWindDB;Trusted_Connection=yes;" );
    cout << stats << endl;
}

4294967295 - INVALID_FILE_ATTRIBUTES. ?

+1

, , GetFullPathName, ? ( )

SHLWAPI , .

0

Source: https://habr.com/ru/post/1727411/


All Articles