0
点赞
收藏
分享

微信扫一扫

asp.net文件编辑器-路径的操作


asp.net文件编辑器-路径的操作_path

asp.net文件编辑器-路径的操作_文件名_02

asp.net文件编辑器-路径的操作_文件读取_03

asp.net文件编辑器-路径的操作_扩展名_04

文件读取.aspx.cs代码如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

public partial class 文件读取 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string[] arrs = Directory.GetFiles(MapPath("files"));//Directory

foreach (string _s in arrs)
{


Response.Write(_s + "<br/>");//读取完整物理路径

}
Response.Write("-----------------------------------------------------------------------" + "<br/>");
foreach (string _s in arrs)
{

string _fname = Path.GetFileName(_s);//path类下的GetFileName
Response.Write(_fname + "<br/>");//读取文件名


}
Response.Write("-----------------------------------------------------------------------" + "<br/>");
foreach (string _s in arrs)
{


string _fname1 = Path.GetFileNameWithoutExtension(_s);
Response.Write(_fname1 + "<br/>");//不带扩展名的文件名

}




}
}

效果如图:


asp.net文件编辑器-路径的操作_path_05




举报

相关推荐

0 条评论