浏览文件服务器端的ASP.NET [英] Browse Files Server-side in ASP.NET

查看:159
本文介绍了浏览文件服务器端的ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个ASP.NET Web应用程序使用的.NET包装为计划任务的远程位置安排我们的服务器上的任务。不过,我卡住了。

I'm creating an ASP.NET web application to schedule tasks on our server from a remote location using a .NET Wrapper for Scheduled Tasks. However, I'm stuck.

用户需要能够浏览服务器上的文件系统来检索一个文件以运行为创建在本申请中该用户的新的任务。我需要得到的文件路径/文件名,并把它传递到.NET包装。

The user needs to be able to browse the file system on the server to retrieve a "file to run" for the new task that the user's creating in this application. I need to get the filepath/filename and pass it into the .NET wrapper.

我已经使用HTMLInputFile试过,但我还没有找到一种方法,使这项工作对我来说。

I've tried using HTMLInputFile, but I haven't found a way to make that work for me.

任何帮助是AP preciated。

Any help is appreciated.

感谢



更新:

对于这个项目,我们决定简单地列出一个下拉框的可执行文件,这将是提供给用户,因为他们并不真正需要对文件系统的完全访问,只是为了安全起见。


Update:
For this project, we've decided to simply list the executables in a dropdown box that would be available to users since they don't really need total access to the file system, just for security's sake.

推荐答案

HTMLInputFile用来浏览客户端的文件系统,文件上传到服务器。它不是用来浏览服务器的文件系统。

HTMLInputFile is used to browse the client's file system and upload a file to the server. It isn't used to browse the server's file system.

您将需要完全不同的东西。你会需要一些服务器端code通过浏览器来显示服务器端文件夹结构给用户。

You will need something quite different. You will need some server side code to display the server side folder structure to the user via the browser.

有一个基本的实现这种的例子在这里

There is an example of a basic implementation of this here.

更新:

使用该样本,您替换yourfolderHere与需要是一个虚拟路径,而不是绝对路径。因此,例如C:\\的Inetpub \\ wwwroot的\\上传,将无法正常工作,但上传将工作

With that sample, the path that you replace "yourfolderHere" with needs to be a virtual path, rather than an absolute path. So for example "C:\Inetpub\wwwroot\uploads" won't work, but "uploads" will work.

我希望这不用说,存在严重的安全问题需要考虑这样的实施东西的时候。

I hope it goes without saying that there are serious security issues to think about when implementing something like this.

这篇关于浏览文件服务器端的ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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