How do you add a file to an existing project in Codelite? - c++

I've got my workspace, project and a single file currently. I want to add an additional file to my src folder but can't figure out how.
I tried adding a new file to my project folder using ctrl+N and it shows up with my first file when I go to Edit -> Open file. However, it won't show up in my src folder while I've got my workspace/project open; that part is still only showing the original file I created when I made the project.

Right click on the src folder and select Add an existing file

Related

Adding a CSV file to a project in Visual Studio

I am working on a project where I have to read in serveral pre-existing CSV (dog.csv, horse.csv, etc.). I want to know how would I add these file into my project so that I may test to see if my print functions work (the code is written in c++). Would I have to copy and paste the files into the debugging folder or would I place it under the test folder of the project?
You can include the files in your project in whatever (sub)folder you wish by using Right click -> Add -> Existing Item. Then, right-click on each file and choose Properties. Set up "Copy to output directory" to "Copy if newer".
Then after build, your files will be copied into the bin/debug folder.
To read the file, you can just use:
System.IO.File.ReadAllText("dog.csv");
Another possible way is to add a file within project, right click and select properties, and then in Copy to Output Directory, select Copy always. This way, csv file will be automatically copied in your debug and release packages too.
string executableLocation = Path.GetDirectoryName(
Assembly.GetExecutingAssembly().Location);
string csvLocation= Path.Combine(executableLocation, "file.csv");
Above code will read file location from bin directory where your csv file will be stored.
This link should help guide you how to add CSV files to a project.
If you wanted to do a down and dirty way you could just save the CSV's somewhere on your local machine, and then hard code the file path to that location.
Example:
c:\test\Dog.csv and then set that as a variable for whenever you need to read in the csv file.

VS2010 failing to locate source file

My project has following structure:
Someproject
include
workspace
bin
projectspace
source
I am using MFC for dialog based application. I add a new dialog and add a new class.Header and source files are generated in workspace/projectspace folder. I do exclude from project, move the files to respective location (includes/source) and do Add Existing Items in VS. Now when I add a button click event from dialog, it creates a new source file in includes directory. How to avoid this?
You should not do exclude. Instead, copy the files to the desired location, then remove from the project. Then Add existing from the new location.

Open files in NetBeans 8.0.2 are kept in the project file thus making it dirty in GIT

I've been using NetBeans for the last couple of years and only recently upgraded to 8.0.2. It seems that the new project file tracks which files are open in the project workspace (C++) and thus the project file appears as modified whenever I open Netbeans, although I haven't changed anything. Is there a setting to disable this?
Create a file named ".gitignore" in the top-level directory, if it does not
already exist.
Add the line:
nbproject/private/
To do this with Netbeans:
Window -> Files, Select the Directory and right-click for Pop-up.
New -> Other ... -> Empty File.
Name the file ".gitignore"
When you do diffs and commits etc. it should ignore the private files that might have changed.

Cant open html resource file using ifstream::open - Visual Studio 2013

I am working on a project which requires me to open an HTML file and use its contents. I added it to Resource files but when I try to open it lie this:
std::ifstream templateFile;
templateFile.open("filename.html", std::ifstream::in);
The operation fails. I checked it by using templateFile.fail().
The above operation works when I provide the full path. The file lies in the project folder along with other files. I tried setting build action to content but still it doesnt work. Please Help.
Output directory, where your executable is compiled and put into differs from the source directory, where you create all your .cpp/.hpp files (I assume there is filename.html file). Local path filename.html is supposed to be local for your executable file, not the source file.
Read more about changing the output directory here: https://msdn.microsoft.com/en-us/library/ms165410.aspx
Under Configuration Properties / Debugging, see what your Working Directory is using the macros dialog box. Move your file into this folder.
Click the button shown in the figure. There, click either Edit or Browse. Browse will take you to the working directory. Edit will expose the link to open the macros box

Adding pdf as a resource in .qrc

I need to add a pdf file to my resource folder, which I can open from the application with the click of a button (kind of like a Help file).
So my confusions are:
How exactly do I add the pdf to my resources?
What path should I use to direct to the pdf?
QDesktopServices::openUrl(QUrl("/Resource Files/Help.pdf"));
To add the resource file into your project, right click on the project in the Projects pane and click Add New... and then Qt>Qt Resource file, enter a name for it and after finishing something is added to your .pro file like :
RESOURCES = myResource.qrc
Once added into the pro file, a separate .qrc file will be added into your Qt project with which you can double click and add your desired resources like icons, translation files etc. Open the resource file and add your pdf file there.
To open the pdf file from resources, you should first copy it to some location for example in the application directory path :
QFile HelpFile("qrc:/myFile.pdf");;
HelpFile.copy(qApp->applicationDirPath().append("/myFile.pdf"));
Next you can open the pdf file by :
QDesktopServices::openUrl(QUrl::fromLocalFile(qApp->applicationDirPath().append("/myFile.pdf")));