62,046
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.IO;
namespace Asiastar.NR.Ajax
{
/// <summary>
/// $codebehindclassname$ 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class DeleteRes : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
//获取资源编号
string fielid = context.Request["id"];
string[] fileids = fielid.TrimEnd('|').Split('|');//用|分开各个资源编号
Asiastar.NRBLL.File bll = new Asiastar.NRBLL.File();
foreach (string guid in fileids) //遍历编号集
{
if (bll.FN_SerchPathByFileId(new Guid(guid)) != null || bll.FN_SerchPathByFileId(new Guid(guid)).Tables[0].Rows.Count > 0)
{
for (int i = 0 ; i < bll.FN_SerchPathByFileId(new Guid(guid)).Tables[0].Rows.Count ; i++)
{
string path = bll.FN_SerchPathByFileId(new Guid(guid)).Tables[0].Rows[i]["FilePath"].ToString(); //定义变量接收数据库资源完整路径
if (!Directory.Exists(path))
{
try
{
System.IO.File.Delete(path); //如果路径存在 先删除服务器上的文件 在执行对数据库filepath的删除操作
}
catch (Exception ex)
{
context.Response.Write(ex.ToString());
}
NRBLL.File nbf = new Asiastar.NRBLL.File();
if (nbf.FN_DeleteRes(new Guid(guid)) == true)
{
context.Response.Write("0");
}
else
{
context.Response.Write("1");
}
}
}
}
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
}