欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

WinForm實現(xiàn)讀取Resource中文件的方法

 更新時間:2014年08月07日 09:20:17   投稿:shichen2014  
這篇文章主要介紹了WinForm實現(xiàn)讀取Resource中文件的方法,很實用的一個功能,需要的朋友可以參考下

有些情況下,在開發(fā)一些C#小項目的時候,交付給別人用的時候就是單獨EXE文件,但是若涉及什么EXCEL,圖片什么的時候,比較麻煩,這時候可以將EXCEL存放在Resource中,那么怎么讀取出來呢?本文介紹了WinForm實現(xiàn)讀取Resource中文件的方法。項目文件結(jié)構(gòu)如下圖所示:

主要代碼如下:

static string templateXlsPath = string.Format("{0}template.xls", Path.GetTempPath());//存放到臨時文件夾內(nèi)
private void CreateMergeExcel()
{
  byte[] _templateXls = LHResource.template;
  FileStream outputExcelFile = new FileStream(templateXlsPath, FileMode.Create, FileAccess.Write);
  outputExcelFile.Write(_templateXls, 0, _templateXls.Length);
  outputExcelFile.Close();
}

代碼運(yùn)行效果如下圖所示:

相關(guān)文章

最新評論