WinForm实现读取Resource中文件的方法
作者:shichen2014 时间:2021-05-25 18:29:45
有些情况下,在开发一些C#小项目的时候,交付给别人用的时候就是单独EXE文件,但是若涉及什么EXCEL,图片什么的时候,比较麻烦,这时候可以将EXCEL存放在Resource中,那么怎么读取出来呢?本文介绍了WinForm实现读取Resource中文件的方法。项目文件结构如下图所示:
主要代码如下:
static string templateXlsPath = string.Format("{0}template.xls", Path.GetTempPath());//存放到临时文件夹内
private void CreateMergeExcel()
{
byte[] _templateXls = LHResource.template;
FileStream outputExcelFile = new FileStream(templateXlsPath, FileMode.Create, FileAccess.Write);
outputExcelFile.Write(_templateXls, 0, _templateXls.Length);
outputExcelFile.Close();
}
代码运行效果如下图所示:
标签:WinForm,Resource
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Java实现导出word表格的示例详解
2023-01-02 21:36:48
![](https://img.aspxhome.com/file/2023/1/105961_0s.png)
使用Springboot对配置文件中的敏感信息加密
2021-05-24 10:50:25
![](https://img.aspxhome.com/file/2023/0/64020_0s.jpg)
SpringBoot中使用Servlet三大组件的方法(Servlet、Filter、Listener)
2021-07-19 18:41:43
![](https://img.aspxhome.com/file/2023/3/104703_0s.png)
关于各种排列组合java算法实现方法
2023-11-15 05:46:55
Java Resource路径整理总结
2021-11-24 06:52:31
Flutter ListView 上拉加载更多下拉刷新功能实现方法
2023-06-25 19:51:57
![](https://img.aspxhome.com/file/2023/4/89604_0s.gif)
dotnet core链接mongodb代码实例
2023-07-20 14:26:09
深入理解java final不可变性
2023-02-11 20:17:27
![](https://img.aspxhome.com/file/2023/4/62124_0s.jpg)
Java编程中ArrayList源码分析
2023-05-20 00:05:25
springAop实现权限管理数据校验操作日志的场景分析
2023-11-23 10:00:27
Hibernate中load方法与get方法的区别
2021-07-18 09:32:16
java实现钉钉机器人消息推送的示例代码
2023-05-18 13:53:25
![](https://img.aspxhome.com/file/2023/5/82005_0s.png)
C#接口归纳总结实例详解
2021-08-18 16:55:54
java中form以post、get方式提交数据中文乱码问题总结
2022-12-15 06:53:59
![](https://img.aspxhome.com/file/2023/7/63497_0s.png)
web打印 window.print()介绍
2022-10-22 23:50:59
Unity实现俄罗斯方块(二)
2022-01-15 06:57:56
![](https://img.aspxhome.com/file/2023/0/69780_0s.jpg)
java 多态与抽象类详解总结
2022-04-19 10:59:18
![](https://img.aspxhome.com/file/2023/5/67135_0s.jpg)
Java常用函数式接口总结
2022-02-02 00:02:50
![](https://img.aspxhome.com/file/2023/8/68178_0s.png)
详解C# Socket简单例子(服务器与客户端通信)
2022-01-02 03:12:49
![](https://img.aspxhome.com/file/2023/7/102217_0s.jpg)
c#遍历System.drawing.Color下面的所有颜色以及名称以查看
2022-05-12 06:33:19