Implemented three text files in the project. I thought they would be in the project all the time, but they refer to the files in the debug folder, which is not good, because if these files are not on the disk, then there are errors when compiling.
- “They refer to the files in the debug folder” is unclear. Who refers to whom? - VladD
- they refer to files that are physically on the computer. And I need them to be implemented in the project itself. \ - asda
- Who are "they"? - VladD
- What is shown in the screenshot and how does this relate to the issue? - Grundy
- As I understand it, he wants the files to be embedded into the program and on the client side they are not needed. @Grundy, and how do you refer to the file in the code? It seemed to me that VS, by default, sews them into code. - iluxa1810
1 answer
Read the article on MSDN: Adding and Editing Resources (Visual C #)
To add resources to a project, right-click the Properties node in the project in Solution Explorer , click Open , and then on the Resources page in the Project Designer, click the Add Resource button. Resources can be added to the project as linked resources (external files) or as embedded resources (embedded directly into the RESX file).
- When adding a linked resource in the RESX file with project resource information, only the relative path to the resource file on the disk will be indicated. If you add images, videos, or other complex files as related resources, you can change them in the default editor associated with the corresponding file type in the resource designer.
- In the case of embedded resources, the data is stored directly in the project resource file ( RESX ). Strings can only be stored as embedded resources.
After adding files to resources, the added files are placed in the Resources folder located in the project root.
You can also specify an action when building:
- None - the file is not included in the output group of the project and is not compiled during the build process. An example of such a file is a text file of the documentation, for example the Readme file.
- Compile - the file is compiled into the output build files. This setting is used for code files.
- Content - the file is not compiled, but included in the output group "Content". This option is used by default for HTM files and other web files.
- Embedded Resource - the file is embedded in the main output files of the project in the form of a DLL or executable file. Typically, this value is used for resource files.
To set the Build Action
property or the Copy to Output Directory
property of the Build Action
property, you need to go to the properties of the resource file and change the necessary property.
As a matter of fact, you are interested in the Build Action
property, which you need to specify for your needs.
Useful links to explore: