虚拟路径是预期的。 [英] virtual path was expected.

查看:79
本文介绍了虚拟路径是预期的。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试从我的应用程序中打开一个excel文件。它返回一个错误。

''D:/new1.xls''是一个物理路径,但是''D:/ new1.xls''是物理路径,但虚拟路径是预期。



 HttpContext.Current.Response.ContentType =  < span class =code-string> Application / xmsexcel; 
HttpContext.Current.Response.AppendHeader( Content-Disposition attachment; filename = + txt.Text + 。xls);
HttpContext.Current.Response.TransmitFile(Server.MapPath( @ D:\ new1.xls ));



给我解决方案。

解决方案

我自己解决了这个问题... 

HttpContext.Current.Response.TransmitFile(System.IO.Path.GetFullPath(@D:\ new1.xls));


hi, i try to open a excel file form my application. It returns an error.
''D:/new1.xls'' is a physical path, but a''D:/new1.xls'' is a physical path, but a virtual path was expected.

HttpContext.Current.Response.ContentType = "Application/xmsexcel";
     HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" + txt.Text + ".xls");
     HttpContext.Current.Response.TransmitFile(Server.MapPath(@"D:\new1.xls"));


give me solution for this.

解决方案

i get the solution my self ...

  HttpContext.Current.Response.TransmitFile(System.IO.Path.GetFullPath(@"D:\new1.xls"));


这篇关于虚拟路径是预期的。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆