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();
}
Ïà¹ØÎĵµ£º
//private string datapatch = ConfigurationSettings.AppSettings["acessconn"];//Êý¾Ý¿âµØÖ·
private string datapatch = "db/global.asa";//Êý¾Ý¿âµØÖ·
///
/// È¡µÃdataset
//
/// ²éѯÓï¾ä
///
public DataSet GetDataSet(string Commandtext)
{&nbs ......
ÔÚweb configÖÐ ×÷ÈçÏÂÅäÖãº
<connectionStrings>
<add name="ydycon" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=|DataDirectory|ydy.mdb" providerName="System.Data.OleDb"/>
</connectionStrings>
ÔÚ.netÎļþÖÐÓ¦ÓÃÁ´½Ó ......
ÔÚ.Netƽ̨ϽøÐÐCSÈí¼þ¿ª·¢Ê±,ÎÒÃǾ³£Óöµ½ÒÔºó»¹ÒªÓõ½Ä³Ð©±äÁ¿ÉÏ´ÎÐ޸ĺóµÄÖµ,ΪÁ˼òµ¥Æð¼û,ºÜ¶àÈ˶¼Ï°¹ßÓÃstaticÀ´¶¨ÒåÕâЩ±äÁ¿,ÎÒÒ²ÊÇ¡£ÕâÑù·Ç³£·½±ã£¬ÏÂÒ»´Îµ÷ÓÃij¸öº¯Êýʱ¸Ã±äÁ¿ÈÔÈ»±£´æµÄÊÇ´¦Àí¹ýµÄÖµ£¬Ö±½ÓÄÃÀ´ÓþͿÉÒÔÁË¡£
ÏÖÔÚתÈëÁËBSÈí¼þ¿ª·¢£¬ÎÒÃǺÜ×ÔÈ»µØ»áÑØÓ ......
1. Asp.NetÖм¸ÖÖÏàËƵıê¼Ç·ûºÅ: < %=...%>< %#... %>< % %>< %@ %>½âÊͼ°Ó÷¨
´ð: < %#... %>: ÊÇÔڰ󶨿ؼþDataBind()·½·¨Ö´ÐÐʱ±»Ö´ÐУ¬ÓÃÓÚÊý¾Ý°ó¶¨
Èç: < %# Container.DataItem("tit") %>
< %= %>: ÔÚ³ÌÐòÖ´ÐÐʱ±»µ÷Ó㬿ÉÒÔÏÔʾºǫ́±äÁ¿Öµ
Èç:
*.aspxÖУº < %= ......
ʹÓÃGridview°ó¶¨Êý¾Ý¿âÖеÄͼƬ(תÔØ)
×¢£º´ËϵÁмǼÔÚÎÒʵ¼Ê¿ª·¢ÖÐÓöµ½µÄÎÊÌâºÍÊÕ²ØһЩ¼¼ÇÉÎÄÕ¡£
ÎÒÃǶ¼ÖªµÀ£¬ÔÚGridviewÖв»ÄÜÖ±½ÓÈ¥°ó¶¨Êý¾Ý¿âÖеÄͼƬ£¬ÎÒÃÇ¿ÉÒÔÀûÓÃHttpHandlerºÜÈÝÒ×µÄÍê³ÉÕâ¸öÈÎÎñ£¬ÔÚÕâÀïÎҼǼһÏÂÕâ¸ö¹ý³Ì¡£
1.ÉÏ´«Í¼Æ¬´æ´¢µ½Êý¾Ý¿âÖÐ
ÔÚÊý¾Ý¿âÖд´½¨Ò»¸ö±í£¬Ìí¼ÓÒ»ÏÂ3¸ö×ֶΣº
²½ÖèÒ»£ ......