Visual Studio 2015.使用代码添加现有项目(C++)
问题描述:
如何将现有项目添加到使用C++代码的Visual Studio项目中?Visual Studio 2015.使用代码添加现有项目(C++)
//This function creates a simple .txt file
void Example::CreateFile(){
ofstream outputFile("SimpleFile.txt");
outputFile << "Hello";
outputFile.close();
//Here i want to use code to include the file created above to my vs2015 project.
}
编辑:更详细。 This is how you can add new items in VS。使用此选项可以选择要添加到项目中的文件。在我的情况下,我将选择使用代码之前创建的SimpleFile.txt和now the file is included in my project。但是你必须手动完成(第一张图片中显示的方式)。
我想知道是否存在一种方法做相同的,但自动的,所以,当我使用该函数创建一个文件,它会被添加到我的项目,编译包括在源文件中的文件。
谢谢。
答
使用一个项目生成器,就像CMake一样。
Downvoted因为不清楚你问 – 23ars
还有就是未超过能见度用户编译以外的任何文件没有任何好处。并且在代码片段中创建的文件将位于输出文件夹中(而不是源文件的一部分)。 – crashmstr
@crashmstr我也想这样。 –