CommonBussiness/admin/delimg.ashx.cs
(完整代码) 1KBusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
namespace CommonBussiness.admin
{
/// <summary>
/// delimg 的摘要说明
/// </summary>
public class delimg : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string filepath = context.Request["img"].ToString();
int r = 0;
r = r + DelFile(filepath);
context.Response.Write(r);
}
/// <summary>
/// 文件删除
/// </summary>
/// <param name="filepath">文件路径</param>
/// <returns></returns>
public int DelFile(string filepath)
{
int Result = 0;
filepath = System.Web.HttpContext.Current.Server.MapPath(filepath);
if (File.Exists(filepath))//判断文件是否存在
{
FileInfo fi = new FileInfo(filepath);
if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
{
fi.Attributes = FileAttributes.Normal;
}
File.Delete(filepath);//直接删除其中的文件
Result = 1;
}
else { Result = 0; }
return Result;
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。