在其默认应用程序中打开文件 [英] Open a file in its default application

查看:95
本文介绍了在其默认应用程序中打开文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows应用程序中,可以使用以下命令在其默认应用程序中打开文件:

In a windows application, one can open a file in its default application with:

Process.Start(filename);





How can it be done it ASP.NET?

推荐答案

System.Diagnostics.Process.Start()在asp.net中也可以工作.但这将在服务器上启动一个应用程序.

您能解释一下您到底要做什么吗?
System.Diagnostics.Process.Start() works in asp.net as well. But that will start an application on the server.

Could you explain what exactly are you trying to do?


如果要让客户端下载文件,请使用正确的程序打开文件,然后在将文件流式传输给用户之前,应设置正确的内容类型. .

例如一个zip文件:Response.ContentType ="application/zip"
If you want a client downloading a file open it with the correct program you should set the correct content type before streaming the file to the user.

For example a zip file: Response.ContentType = "application/zip"


Well Process.Start(filename);

可以在ASP.NET上工作,但它将尝试在已发布您的网站的服务器上启动此类应用程序.我觉得很奇怪.

我给一个解释:
当您发布任何网站/网络服务时,它将在该计算机的用户"UserName/ASPNET"下运行.
这意味着对于stmt Process.Start(filename); "UserName/ASPNET"用户将尝试启动给定的应用程序,因为它不是管理用户,所以可能不允许该应用程序.

因此,出于安全原因,我认为这是不可能的..
Well Process.Start(filename);

Could have worked on ASP.NET but it will try to launch such application on server, where your website has been published. Which I think weird to see.

I give an explanation :
When u publish any website/webservice it works under user ''UserName/ASPNET'' for that machine.
That means for stmt Process.Start(filename); ''UserName/ASPNET'' user will try to launch the given application, which might not be allowed as it is not an administrative user.

So I feel thats not possible for security reasons..


这篇关于在其默认应用程序中打开文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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