怎么打开.net服务器文件路径,.net c#单击后在文件资源管理器中打开目录

博主探讨了如何在从生产服务器上的partial view中点击文件路径时,绕过浏览器的安全限制,实现本地文件夹的打开。讨论了现有方案的局限性和可能的替代方法,如使用Java Applet与JavaScript交互。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I have a partialView which lists out filepaths and I need to be able to click on that path and open the containing folder.

The app was working locally and process.start() worked just fine until we moved to a production server and now a solution is needed for it.

The browsers security restrictions won't allow me to open the containing folder directly.

Is there a way to accomplish this?

Current setup, pretty basic stuff

public ActionResult OpenFile(string path, int someId)

{

Process.Start("explorer.exe", Path.GetDirectoryName(path));

The view looks like this

@foreach (var file in Model.FileSet)

{

var path = @file.FilePath;

@file.FilePath @file.FileType@file.Created

}

Any help is appreciated.

Solutions1

The code Process.Start is done on server side and even probably works if you check server process list.

You can only add download functionality, but I don't know if this fulfills your requirements.

Talk1:

Thanks @Garath,The files are downloaded through a separate process and reside on the client machine. The file location is stored in the database and listed on the app. So, something that can open files on the local client machine is what i am looking for.

Talk3:

I did look at it before posting my question but thought there's someone out there who encountered this and resolved it.

Talk4:

it cannot be resolved because in all browser, because most of them just block this because of security reasons. If you really need such functionality the only option is to use java applet and communicate with it using javascript.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值