Oct 22, 2014 at 9:43am UTC
Hi,
I'm looking for a way to get the real name of a file.
I have the following file "C:\MY_file.txt".
If I do CreateFile to open it with "C:\my_file.txt" as parameter it works I get a valid handle because IMO win32 is not case-sensitive.
Then I would like to know that the real name is not "my_file.txt" but "MY_file.txt".
Any help is greatly appreciated.
Best Regards,
Bernard
Oct 22, 2014 at 4:54pm UTC
Sorry but it doesn't work.
Oct 22, 2014 at 5:18pm UTC
@ OP: Would you care to elaborate? It works fine when I compile it. Are you getting an error? Is the result not what you expected? Is your application crashing?
Oct 22, 2014 at 5:31pm UTC
So much for the new fancy stuff.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#ifdef _UNICODE
#undef _UNICODE
#undef UNICODE
#endif
#include <Windows.h>
#include <iostream>
int main()
{
WIN32_FIND_DATA find_data = {};
if (HANDLE hFindHandle = FindFirstFile("C:\\TEMP\\HELLO.CLASS" , &find_data))
{
std::cout << "Real Name: " << find_data.cFileName << std::endl;
std::cout << "8.3 name: " << find_data.cAlternateFileName << std::endl;
FindClose(hFindHandle);
}
return 0;
}
Real Name: Hello.class
8.3 name: HELLO~1.CLA
Last edited on Oct 22, 2014 at 5:33pm UTC
Oct 22, 2014 at 7:36pm UTC
Was in a hurry I apologize for my short answer.
Thanks kbw for the solution I appreciate it.