asp.net postedFile.SaveAs和SaveAs,解决了本地查看excel找不到System.IO.Path.GetFileName文件问题
来源:互联网 发布:java web开发面试宝典 编辑:程序博客网 时间:2024/05/18 01:51
注:
fileupload.SaveAs("完整路径带文件名")
fileupload.postedFile.SaveAs("文件名")
Server.MapPath获得服务器的路径
本地浏览excel总是失败,找了半天原因,其实是一个文件夹没有共享出来,权限是EveryOne(可读写最好完全控制)
//DropDownList2是上传的excel内的sheet(表名称)//fileupload是input控件//Label1用来存储文件名//不同主机上浏览IPDropDownList是可选IP地址public void Excel2007_Click(object sender, EventArgs e) { if (this.fileupload.Value == "" && this.Label1.Text == "" && DropDownList2.SelectedValue == "") { Response.Write("<script>window.alert('请选择要导入的文件')</script>"); } if (this.fileupload.Value != "" && this.DropDownList2.SelectedValue == "") { string tempsr = ""; HttpFileCollection files = HttpContext.Current.Request.Files; HttpPostedFile postedFile = files[0]; fileName = System.IO.Path.GetFileName(postedFile.FileName); if (fileName != "") { tempsr = "\\\\" + IPDropDownList.SelectedValue + "\\文件\\" + fileName; postedFile.SaveAs(tempsr); } string strConn; strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + tempsr + ";Extended Properties=Excel 8.0;";//试用Excel03-07版本 OleDbConnection conn = new OleDbConnection(strConn); conn.Open(); DataTable sheetNames = conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" }); foreach (DataRow dr in sheetNames.Rows) { DropDownList2.Items.Add(dr[2].ToString()); } this.Label1.Text = tempsr; conn.Close(); }
- asp.net postedFile.SaveAs和SaveAs,解决了本地查看excel找不到System.IO.Path.GetFileName文件问题
- [ASP.NET] FileUpload SaveAs() access to the path is denied
- EXCEL SAVEAS XlFileFormat 详解
- ASP.NET中用HttpPostedFile.SaveAs(FileName)方法上传文件,文件大小限制
- MFC API实现Excel读写 屏蔽调用SaveAs函数时弹出“文件已存在”问题
- Excel.Application: SaveAs之fileformat
- Excel.Application: SaveAs之fileformat 收藏
- C# 保存excel的SaveAs方法详述
- 在ASP.NET 2.0中,有时候需要对ASP.NET生成的HTML代码进行处理,或者是保存成静态文件。ASP.NET 提供了直接将请求保存成文件的方法:HttpRequest.SaveAs方法。下面这个方法就是在ASP.NET 2.0中得到ASP.NET
- matlab saveas 和imwrite的区别
- matlab saveas 和imwrite的区别
- 解决Asp.net页面找不到ajaxpro相关文件问题
- OFFICE EXCEL 中为什么两次用SAVEAS 会出错?
- QT操作Excel调用SaveAs保存成2003格式
- C#中Excel的Workbook对象的SaveAs方法
- C# 导出Excel的WorkBook的SaveAs方法
- ASP.NET FileUpload.PostedFile.ContentType
- WorkBook的SaveAs方法
- mac os平台编译jaberd
- jdk时间差问题
- Image Alignment Algorithms
- Ubuntu定时备份Postgres
- Unity3D Resources Load 资源加载测试
- asp.net postedFile.SaveAs和SaveAs,解决了本地查看excel找不到System.IO.Path.GetFileName文件问题
- 美领店父员农在私园疏吻路己 高叫不要脸
- myeclipse中的web项目转eclipse
- Fbx Scene变换
- 联通SGIP发送短信
- DLL接口的实现(虚函数)
- Android开发实用小工具
- 摄像头编程WindowsAPI - avicap32.dll 参数详解
- MyEclipse下XFire开发Webservice实例