在asp.net中下载文件 [英] File Download in asp.net

查看:70
本文介绍了在asp.net中下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

i在asp.net下载文件有问题。

i在我的项目中有一个文件夹,包含很多jpg文件,点击我想要的按钮下载文件。

如何用fileinfo创建文件的路径?我不希望路径为c:\\\ .jpg

但它是〜/ uploads / 1.jpg然后fileinfo找不到文件。

任何想法?

任何解决方案?

谢谢。

hello
i have a problem with download file in asp.net.
i have a folder in my project and contains many jpg files,when click on a button i want to download a file.
how i can create the path of file with fileinfo?i dont want the path be "c:\1.jpg"
but it is "~/uploads/1.jpg" then fileinfo can not find the file.
any idea?
any solution?
thank you.

推荐答案

参考



下载文件 - 从服务器到客户端 - 使用-asp-net-when-file-size-using-generic-handlers-ashx / [ ^ ]


您可以使用以下代码获取路径





You can get the path by using the folllowing code


string cvFilePath = Server.MapPath("~/uploads/1.jpg");
FileInfo fiCv = new FileInfo(cvFilePath);


http://msdn.microsoft.com/en-us/library /system.web.httpserverutility.mappath%28v=vs.110%29.aspx [ ^ ]


这篇关于在asp.net中下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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