opening folders

Nov 14, 2021 at 3:53pm
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 Nov 15, 2021 at 10:36am
Nov 14, 2021 at 4:27pm
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
Nov 14, 2021 at 4:31pm
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.
Nov 14, 2021 at 4:39pm
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.
Nov 14, 2021 at 4:42pm
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.
Nov 14, 2021 at 5:41pm
You still haven't moved this to the Windows forum. Any chance of doing that please?
Nov 14, 2021 at 7:44pm
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
Nov 14, 2021 at 8:04pm
Yeah, using <filesystem> makes a program OS agnostic. *nix, Mac or Win, same code, just differing format for a directory path.
Nov 15, 2021 at 11:51am
It seems the OP wants to open a folder in Windows Explorer.
What does this have to do with std::filesystem ?
Nov 15, 2021 at 2:39pm
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 Nov 15, 2021 at 2:40pm
Topic archived. No new replies allowed.