I created a resource, but the files inside it appear as not existing
I have put my files as a resource in my C # program. Now I am trying to see if files exist or not via
if(File.Exists(path))
but it doesn't go into the if block when even the path is a valid path to files inside resources. The files are DTDs that will be embedded as resources within an assembly at compile time and resolved as resources at run time. Please help. what could be the reason? and what am I missing?
0
chh
a source
to share
3 answers
Since you have embedded the resource, the file (or resource) is embedded in the assembly manifest. You may have to grab the file as a resource stream from the manifest.
string filePath = Assembly.GetExecutingAssembly().GetName().Name+"." + resourceFileName;
Stream fileStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(filePath);
+1
a source to share