问题
So, I have a workbook which is pretty complicated to reproduce programatically. To make my work faster and easier I am looking for a solution to "store" the workbooks into my VSTO to be free to open a copy of it. It seems useful to me but I haven't find any way to do it for now. I hope someone can help me to do it or explain to me how to do a better way.
回答1:
You can just include it to the VSTO add-in installer along with other files. So, the workbook will be kept with other add-in files in the installer folder. At any point of time, you can make a copy. There is no need to include it in the resources.
Anyway, in case if you need to extract the file from resources on the fly, see Extract embedded resources in C#:
System.IO.Stream fs = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(currentResource);
string scriptContents = new StreamReader(fs).ReadToEnd();
File.WriteAllText(destFile, scriptContents);
But your antivirus software may not be happy with this solution!
回答2:
So with the help of Eugene i figured a way to do. And it allow me to help another people so to more information see my answer on :
https://stackoverflow.com/a/62777392/13069899
Thanks.
来源:https://stackoverflow.com/questions/62555578/store-and-open-a-workbook-in-vsto-as-resource