Store and open a Workbook in VSTO as “resource”

痞子三分冷 提交于 2021-01-29 09:20:46

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!