ASP.NET自定义目录浏览处理程序
创始人
2024-09-19 23:01:22
0

ASP.NET自定义目录浏览处理程序可以通过以下步骤来实现:

  1. 创建一个新的ASP.NET Web应用程序项目。

  2. 在项目中创建一个名为"CustomDirectoryBrowser"的新文件夹。

  3. 在"CustomDirectoryBrowser"文件夹中创建一个名为"CustomDirectoryBrowser.ashx"的新文件。

  4. 在"CustomDirectoryBrowser.ashx"文件中添加以下代码:

using System;
using System.Web;

public class CustomDirectoryBrowser : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        string path = context.Request.QueryString["path"];
        string[] files = System.IO.Directory.GetFiles(path);
        string[] directories = System.IO.Directory.GetDirectories(path);

        context.Response.ContentType = "text/html";
        context.Response.Write("");

        // 显示文件
        foreach (string file in files)
        {
            context.Response.Write($"{System.IO.Path.GetFileName(file)}
"); } // 显示文件夹 foreach (string directory in directories) { context.Response.Write($"{System.IO.Path.GetFileName(directory)}
"); } context.Response.Write(""); } public bool IsReusable { get { return false; } } }
  1. 在项目的"Web.config"文件中添加以下代码,以将"ashx"文件映射到"CustomDirectoryBrowser"处理程序:

  
    
      
    
  

  1. 构建和运行应用程序。

  2. 在浏览器中访问"/CustomDirectoryBrowser.ashx?path=您的文件夹路径",将显示指定文件夹中的文件和文件夹。

相关内容

热门资讯

wpk模拟器多开!hhpoke... wpk模拟器多开!hhpoker的辅助是真的吗(透视)攻略-好像解谜存在有挂hhpoker的辅助是真...
透视普及!aapoker脚本(... 透视普及!aapoker脚本(透视)德州透视hhpoker,教程窍门(揭秘有挂)-哔哩哔哩1、起透看...
透视曝光!hhpoker视频巡... 透视曝光!hhpoker视频巡查真的假的(透视)hhpoker软件安装包,教程指南书(确实有挂)-哔...
pokemmo脚本辅助器!we... pokemmo脚本辅助器!wepoker怎么下载游戏(透视)技巧-一贯专业有挂小薇(辅助器软件下载)...
wepoker好友局透视!德普... wepoker好友局透视!德普之星辅助器(透视)插件-本来开挂有挂1、wepoker好友局透视免费辅...
哈糖大菠萝开挂!aa poke... 您好,哈糖大菠萝开挂这款游戏可以开挂的,确实是有挂的,需要了解加去威信【485275054】很多玩家...
透视详细!智星德州可以透视吗(... 透视详细!智星德州可以透视吗(透视)poker红龙辅助,教程经验(有挂细节)-哔哩哔哩1、实时智星德...
淘宝买wepoker透视有用吗... 淘宝买wepoker透视有用吗!hhpoker辅助(透视)方法-总是揭露存在有挂1、金币登录送、破产...
透视详情!wpk透视辅助下载(... 透视详情!wpk透视辅助下载(透视)智星菠萝透视,教程大纲(有挂细节)-哔哩哔哩1、wpk透视辅助下...
wepoker祈福有用吗!hh... wepoker祈福有用吗!hhpoker怎么防透视(透视)教程-一贯揭幕有挂hhpoker怎么防透视...