Arashdn
Arashdn

Reputation: 731

Get list of files in application directory

I am developing a C++ application for win32 console

I need to get list of files in my application directory

(for example if my application had been started in C:\arash\app\ I need list of files in this folder)

I searched and find FindFirstFile function in windows.h header , But this function need a directory path .

Can I use this function for getting list of files in my application running directory?

Thanks

Upvotes: 1

Views: 427

Answers (2)

Open AI - Opting Out
Open AI - Opting Out

Reputation: 24133

The current working directory is '.'.

As noted in comments, this isn't necessarily the directory you want.

Upvotes: 1

Remy Lebeau
Remy Lebeau

Reputation: 596156

Use GetModuleFileName() with a NULL module handle to get the path and filename of the .exe file. You can then strip off the filename portion, and use the remaining path as needed.

Upvotes: 4

Related Questions