【发布时间】:2014-10-15 11:23:43
【问题描述】:
我当前的项目使用此 excel 文档的直接文件路径从 excel 文件中读取信息。我需要让我的项目准备好发布,所以我不能让项目硬编码字符串形式的文件路径。
我想将 Excel 文件嵌入到我的资源中,我已经完成了,但知道如何从 Resource 获取文件路径,并将文件路径发送到读取 Excel 文件的类。该类必须提供文件路径,因此我正在考虑制作此 Excel 文件的副本,然后在 Temp 文件夹中引用该类的文件路径以读取 Excel 文件。
FileName = @"D:\SomeFolder\ExcelFile.xlsx"; //This is the old code, hard coded
//I need code that is going to make a copy of this file from the Resources and save it somewhere in a temp folder, but then give me
the File path in the form of a string.
string FileName;
// I need the file name to have the directory of this excel that is in the Resource folder
//Call Class to Create XML File and store Data from BIN File Locally on Program
ReadExcel_CreateXML = new ExcelRecorder(FileName);
【问题讨论】:
标签: c# visual-studio-2010 resources