Can not use Directory::GetCurrentDirectory() in C++?

G

Guest

Why ?

void foo()
{
Directory::GetCurrentDirectory() ;
}
----------Compile Error-----------------------
C2039: 'GetCurrentDirectoryA' : is not a member
of 'System::IO::Directory'
 
C

Carl Daniel [VC++ MVP]

Why ?

void foo()
{
Directory::GetCurrentDirectory() ;
}
----------Compile Error-----------------------
C2039: 'GetCurrentDirectoryA' : is not a member
of 'System::IO::Directory'

You've #included <windows.h>, which #defines GetCurrentDirectory as a macro
that expands to either GetCurrentDirectoryA or GetCurrentDirectoryW.

It's best to avoid using Win32 API names in your own code to avoid such
problems, but you can also just #undef GetCurrentDirectory after your
#includes.

-cd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top