Asp.net对文件夹和文件的操作类
using System;
using System.IO;
using System.Web;
namespace SEC
{
/**////
/// 对文件和文件夹的操作类
///
public class FileControl
{
public FileControl()
{
}
/**////
/// 在根目录下创建文件夹
///
///
要创建的文件路径
public void CreateFolder(string FolderPathName)
{
if(FolderPathName.Trim().Length> 0)
{
try
{
string CreatePath = System.Web.HttpContext.Current.Server.MapPath
("../../../Images/"+FolderPathName).ToString();
if(!Directory.Exists(CreatePath))
{
Directory.CreateDirectory(CreatePath);
}
}
catch
{
throw;
}
}
}
/**////
/// 删除一个文件夹下面的字文件夹和文件
///
///
public void DeleteChildFolder(string FolderPathName)
{
if(FolderPathName.Trim().Length> 0)
{
try
{
string CreatePath = System.Web.HttpContext.Current.Server.MapPath
(FolderPathName).ToString();
if(Directory.Exists(CreatePath))
{
Directory.Delete(CreatePath,true);
}
}
catch
{
throw;
}
}
}
/**////
/// 删除一个文件
///
///
public void DeleteFile(string FilePathName)
{
try
{
FileInfo DeleFile = new FileInfo(System.Web.HttpContext.Current.Server.MapPath
(FilePathName).ToString());
DeleFile.Delete();
}
catch
{
}
}
public void CreateFile(string FilePathName)
{
try
{
//创建文件夹
string[] strPath= FilePathName.Split('/');
CreateFolder(FilePathName.Replace("/" + strPath[strPath.Length-1].ToString(),"")); //创建文件
夹
FileInfo CreateFile =new FileInfo(System.Web.HttpContext.Current.Server.MapPath
(FilePathName).ToString()); //创建文件
if(!CreateFile.Exists)
{
FileStream FS=CreateFile.Create();
FS.Close();
}
}
catch
{
}
}
/**////
/// 删除整个文件夹及其字文件夹和文件
///
///
public void DeleParentFolder(string FolderPathName)
{
try
{
DirectoryInfo DelFolder = new DirectoryInfo(System.Web.HttpContext.Current.Server.MapPath
(FolderPathName).ToString());
if(DelFolder.Exists)
{
DelFolder.Delete();
}
相关文档:
AJAX技术所提倡的无刷新回调,在原来的技术中需要写大量的JavaScript代码或使用一些AJAX框架,使得开发效率和可维护性大大降低。其实ASP.NET2.0中,已经提供了这样的接口,这就是ICallbackEventHandler。
ICallbackEventHandler存在于System.Web.UI中,我们先做一个非常简单的例子来试用一下。
第一步,在VS2005中建 ......
1 目的
2 范围
3 注释规范
3.1 概述
3.2 自建代码文件注释
3.3 模块(类)注释
3.4 类属性注释
3.5 方法注释
3.6 代码间注释
4   ......
以下类容为转载,但是不知道是什么原因,经本人测试这个方法有一个bug,按照以下类容所设计的角色验证不能成功。Application_AuthorizeRequest事件改为Application_AuthenticateRequest事件才能实现。
Asp.net的身份验证有有三种,分别是"Windows | Forms | Passport",其中又以Forms验证用的最多,也最灵活。
Forms 验证 ......
/// <summary>
/// 得到站点用户IP
/// </summary>
/// <returns></returns>
public
static
string
getUserIP()
{
retu ......