I have three excel and one powerpoint file that I need in my Windows Forms Application
. My goal is that they will be compiled into the exe, so the tool can be used from anywhere without dependencies to our LAN folders.
I already tried to drop them into the Resources-Folder in the solution explorer but using them afterwards I have a path like (Z://yourexelfile.xlsx)
. Second thought was to add them as resources in the Project->Properties->Ressources
and access them afterwards via MyProject.My.Resources.Template
but this does not work as well since my functions need a "String" (in this case a path) in the constructor. I tried System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames but this does not give me the needed path just something like MyApp.Resources.resources. It would be great if anyone could help me with it.
Asked
Active
Viewed 77 times
0
-
1You can read the files bytes, hardcode the bytes into the code, and write them to a temp file when you want to use the files on runtime. Silly idea, but simple to do, considering only 3 files are at hand. – SimpleVar Apr 24 '15 at 07:42
-
1@YoryeNathan rather than hardcoding, adding files to Properties/Resources allows just that, to get them as a byte[]. – NLindbom Apr 24 '15 at 08:04
-
@NLindbom That's pretty neat. Who thought of that?! :3 – SimpleVar Apr 24 '15 at 10:22