How can I make Visual Studio save my C++ files in a specific folder?

0
5
Asked By MellowPine47 On

I'm a complete beginner learning C++ in Visual Studio. I created a folder for my files and even tried opening Visual Studio from that folder, but new files created through the File menu are treated as unsaved documents and Visual Studio asks me to choose a location for each one when I close it. I'd like my .cpp files to be saved automatically in the folder I choose. What is the correct way to set this up?

3 Answers

Answered By QuietRiver36 On

Opening a folder in Visual Studio and creating a new file from the main File menu is different from adding a file to a C++ project. A project keeps track of its source files, while a loose new document has no permanent location until you save it. Create or open the project, find it in Solution Explorer, and use Add > New Item there.

Answered By CrispLemon8 On

The easiest approach is to create a C++ project in the folder you want, then use Solution Explorer rather than the general File > New File command. Right-click the project or its source-files folder, choose Add > New Item, select a C++ file, and give it a name. Visual Studio will add and save the file inside that project automatically.

MellowPine47 -

I was opening the folder and creating a file from the File menu, so it stayed as an unsaved document. I’ll try adding the file through Solution Explorer instead.

Answered By NorthStarMango21 On

When creating a new project, check the project location field and select your preferred parent folder. After the project is created, all files added through the project in Solution Explorer will use the project’s folder structure. You can also change Visual Studio’s default project location in its settings, but that only controls the starting location for new projects; it doesn’t automatically save loose files opened from a folder.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.