How can I detect the names of files in a folder in Visual C++? - visual-c++

I have a folder that is containing text files (.txt). In my application I must read all files from this folder. But I don't know the names of these files and how many files in the folder. My application is C++ console application in MS VS 2013 without MFC support and without BOOST. Is there any function in Visual C++ that allows to detect the names of the files placed in specified folder and returns these file names? For example the name of the folder is SomeFolder. I'll be very much obliged to you for help.

There are multiple ways of enumerating files within a folder such as WinAPI32 (FindFirstFile & FindNextFile) or MFC (CFileFind class).
The following are examples of either way:
How to get list of files in a directory programatically
Recursive file search using C++ MFC?

Related

Haskell Extension for Visual Studio Code starts a new Haskell Language Server for each file

I recently installed the Haskell extension in Visual Studio Code which is powered by the Haskell Language Server. Each time I open a different Haskell file in the editor a new process named "haskell-language-server-1.0.0-linux-8.6.5" is created. The result of this is that each time I hover over a word in my program I see everything, like types or errors written two times. More important each of these processes consumes about 1 Gb of RAM and eventually my system crashes. Is there anything I could do to avoid all of this?
I encountered The same problem.
To solve this problem, I opened the folder containing all wanted files, i.e.,File -> Open Folder. This solution is sufficient if you have all wanted files located within a single folder. This folder can contain other folders that also contain haskell files (or any similiar recursive file structure), and still only one language server will be created
If you want to use files that are located in different folders, there are two options depending on how many language servers you are willing to tolerate:
Single Language Server: Move all folders containing wanted files to a new folder; as visual studio code views this as a single folder, only a single language server is spawned.
Specific Limit of Language Servers: Create a workspace and add folders containing wanted files to it. More specifically: a) Close any current workspace, folder, or file( these actions can be found at the bottom of the file menu), b) add wanted folders to workspace by File->Add Folder to Workspace, c)(optional) If you want to use such a setup in the future you can save this workspace by File -> Save WorkSpace as. Each added folder that is added directly through the Add folder to Workspace action will spawn a new language server;it is the number of folders opened this way that determines the amount, not the total amount of folders open.

Is it possible to define a macro for major minor build revision?

I am building a C++ DLL in Visual C++ and would like to append the file version number from the resource file to the resulting DLL name to allow multiple DLL versions to exist in a single folder. i.e.:
MyDLL.1.0.3.44.dll
MyDLL.1.0.3.45.dll
I can't seem to find a macro for the version and therefore cannot programmatically set the output file name.
Is this possible and if so, how?

loading file without whole path visual studios 2012

I am writing a program in Visual Studio 2012. I am using Windows Imaging component I want to put image files for my program to use without them being resources. I want to make them download with the program when someone downloads it.
So my problem is if I specify the direct path in the program say:
C:\Users\Billy\Documents\Background.
How would I do that without having to specify Users\Billy\Documents. Since it will be different on others computers.
Call SHGetFolderPath to get any of the user-dependent path names. Then concatenate the file name to the retrieved path.

Including files in VS 2012

I want to include a library - I've downloaded it and found exactly four files inside:
.h
.lib
.dll
.def
I've put the header file inside of my project. That's the only thing I did - and the visual throws an error that it cannot open the .lib file.
So I immediately wanted to beg for help on stackoverflow, but I've decided to do a little research first. I've found out that the .dll file should be placed inside of the windows/SYSWOW64 location (for my 64-bit windows 7), I placed it there but VS still displays the same error.
How should I deal with that? Did I missed some step during the "installation"? If so, which ones?
You have to specify the path to the library (*.lib) in your project settings.
(You can put it also into your directory with sources)
The presence of DLL file during build is not required.

combining pdb file,xml config file and a dll into a single file

I have three files in the bin folder. While building,I am getting these files.one dll file,one application file(which has no extension),one xml configuration file(which has .exe extension). How it is possible to combine these 3 files into a single exe?..I am running C# winform application
It is impossible to combine them, but you don't need to distribute the .xml or .pdb files, they are just for debugging.

Resources