【发布时间】:2014-01-18 04:31:47
【问题描述】:
我的文件夹中有一个 excel 文件。但我不知道从文件夹中获取该文件。
但我正在检查文件是否存在。
这是我的代码:
protected void Page_Load(object sender, EventArgs e)
{
string filePath = Server.MapPath("~/Upload/Sample.xlsx");
bool fileexists = File.Exists(filePath); //Here fileexists = true
}
我需要将该excel文件保存在sql数据库中。
我需要将该excel文件的fileName(varchar(256)),Data(varbinary(max)),Path(varchar(256))保存到sql数据库中。
请帮帮我
【问题讨论】:
-
您所要做的就是将文件转换为流,然后转换为字节数组,并使用任何标准的
ADO.NETdb 类将其保存在 db 中,您这样做有没有遇到任何问题?你试过了吗? -
将文件转换为byte[] (stackoverflow.com/questions/2030847/…) 并获取名称和路径并保存。如果可以保存很多文件,我个人建议只保存路径和名称。