Please tell me how to use the file (.txt) in the code that is in the Resources project.

    1 answer 1

    If you believe a similar answer in English , then

    You can use the Assembly.GetManifestResourceStream method:

    1. Add the following using

       using System.Reflection; 
    2. Set the following property to the desired file:

      Build Action , Embedded Resource Value

    3. Use the following code

       var assembly = Assembly.GetExecutingAssembly(); var resourceName = "MyCompany.MyProduct.MyFile.txt"; using (Stream stream = assembly.GetManifestResourceStream(resourceName)) using (StreamReader reader = new StreamReader(stream)) { string result = reader.ReadToEnd(); } 

    resourceName name of the built-in resource. For example, if you add the file "MyFile.txt" , which lies in the project root with the default namespace "MyCompany.MyProduct" , then the resourceName will be "MyCompany.MyProduct.MyFile.txt" .
    If you need to get a list of all resources in an assembly, you can use the Assembly.GetManifestResourceNames method.