opening folders

hello so i wanted to open a folder using c++, i found a post already but that didn't work, it would just open documents instead of the folder i wanted.
the code: system("explorer C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp");
if anybody can help me with opening this folder using c++ thx.
-gameplanetworld
Last edited on
This is Windows question, so please move it there.

You might want to consider using ShellExecute rather than system.
https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutea
https://microsoft.public.vc.mfc.narkive.com/qywvLxiJ/shellexecute-open-folder-and-select-file
hello so i wanted to open a folder using c++, i found a post already but that didn't work, it would just open documents instead of the folder i wanted.
the code: system("explorer C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp");
if anybody can help me with opening this folder using c++ thx.
-gameplanetworld


and once this 'folder' is open, what do you want to do to it?
all opening a folder is, is listing the files in it. You can do that using <filesystem> ... maybe try https://en.cppreference.com/w/cpp/filesystem/directory_iterator ?

GUI interfaces can also "open" a folder, which really, as above, is just a graphical way to list the contents, along with the interface to open sub folders or files contained inside them.
i wanted to open a folder using c++

A C++ answer to a Windows® question:

C++17's <filesystem> library.

https://en.cppreference.com/w/cpp/filesystem

Set the path to your desired folder, what you do with the folder's path is up to you.
Not sure what you're trying to do.
You might consider the <filesystem> library (requires C++17).
https://en.cppreference.com/w/cpp/filesystem

Using recursive_directory_iterator you can navigate through a directory and it's subdirectories until you find what you want.
You still haven't moved this to the Windows forum. Any chance of doing that please?
why is it a win question? his system call is on win, sure, but that's all we have?
from c++ a unix folder or windows folder, same thing to filesystem
Yeah, using <filesystem> makes a program OS agnostic. *nix, Mac or Win, same code, just differing format for a directory path.
It seems the OP wants to open a folder in Windows Explorer.
What does this have to do with std::filesystem ?
nothing.
its how you interpret "if anybody can help me with opening this folder using c++ thx."
if you read that as "how to fix the system call" then maybe its a windows topic. If you read it as how to get at the folder in c++, its generic?
Last edited on
Topic archived. No new replies allowed.