Embedding a resource in exe and using the resource file name as string

  Uncategorised

I am using itext to convert some files into PDF format. I found an article (here: https://adamthetech.com/2011/06/embed-dll-files-within-an-exe-c-sharp-winforms/) that explains how to embed .dll into the .exe file, so that I can distribute only one .exe file rather than an installer.
I would like to use the same approach for the color profile that I use, which is sRGB_CS_profile.icm. I added this file as a resource to the solution, but I am having an hard time to get this file name available in my code. I need to use a string in my code that holds this file name, and the .exe to hold and read this file. Example:

string INTENT = "sRGB_CS_profile.icm";

PdfDocument pdf = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "https://www.color.org", "sRGB IEC61966-2.1", new FileStream(INTENT, FileMode.Open, FileAccess.Read)));

How can I have the program find the resource, read it, and use its file name as a string?
Thanks.

Source: Visual Studio Questions

LEAVE A COMMENT