I am trying to save an empty Access database (.mdb) as a resource in my application. Then I want to write it to the file system and populate it with table definitions, etc. The problem that I have in Visual Studio 2005 and my C # application does not have access to the resource stored in the same assembly (which I would seem to be available by default). Here is my code:
byte[] abytResource; System.Reflection.Assembly objAssembly = System.Reflection.Assembly.GetExecutingAssembly(); objStream = objAssembly.GetManifestResourceStream("empty.mdb"); abytResource = new Byte[objStream.Length]; objStream.Read(abytResource, 0, (int)objStream.Length); objFileStream = new FileStream(newDatabasePathWithName, FileMode.Create); objFileStream.Write(abytResource, 0, (int)objStream.Length); objFileStream.Close();
GetManifestResourceStream also returns NULL according to the documentation, since the resource must be private (because even if it does not exist, a value other than NULL is returned). So my question is this:
How to make my resource available for my own application? I already added it to the project and marked it as "Embedded Resource", by the way.
Thanks!
Karim
source share