【毕业论文】基于HTML5 CSS3的相册设计与实现(6)

2018-11-19 20:22

//获取路径

string dictionName = Server.MapPath(\ if (!Directory.Exists(dictionName)) {

//根据获取到的路径创建目录

Directory.CreateDirectory(dictionName); initFenleis(); } }

分类列表使用了一个asp.net 的Repeater控件

前台控件代码:

<%#Container.ItemIndex + 1 %>

<%#GetDataItem()%>

OnClientClick=\删除分类后将连分类内的图片一起删除确认要删除吗?')\删|?除y

- 22 -

后台数据绑定代码: public void initFenleis() {

string[] dict = getFenlei(); for (int i = 0; i < dict.Length;i++ ) {

dict[i] = dict[i].Substring(dict[i].LastIndexOf(\dict[i].Length - dict[i].LastIndexOf(\ }

Repeater1.DataSource = dict; Repeater1.DataBind();

}

//获取分类列表 public string[] getFenlei() {

string filepath = Server.MapPath(\

string[] filenames = Directory.GetDirectories(filepath); return filenames; }

点删除时调用的代码:

protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) {

if (e.CommandName.Equals(\ {

string dic = e.CommandArgument.ToString(); DeleteFolderAll(Server.MapPath(\ }

initFenleis(); }

//初始化分类列表

- 23 -

///

/// 删除文件夹及其内容 ///

///

public static void DeleteFolderAll(string dir) {

foreach (string d in Directory.GetFileSystemEntries(dir)) {

if (File.Exists(d)) {

FileInfo fi = new FileInfo(d);

if (fi.Attributes.ToString().IndexOf(\ fi.Attributes = FileAttributes.Normal; File.Delete(d);//直接删除其中的文件 } else {

DeleteFolder(d);////递归删除子文件夹 Directory.Delete(d); } }

Directory.Delete(dir); }

///

/// 清空指定的文件夹但不删文件夹 ///

///

public static void DeleteFolder(string dir) {

foreach (string d in Directory.GetFileSystemEntries(dir)) {

- 24 -

if (File.Exists(d)) {

FileInfo fi = new FileInfo(d);

if (fi.Attributes.ToString().IndexOf(\ fi.Attributes = FileAttributes.Normal; File.Delete(d);//直接删除其中的文件 } else {

DirectoryInfo d1 = new DirectoryInfo(d); if (d1.GetFiles().Length != 0) {

DeleteFolder(d1.FullName);////递归删除子文件夹 }

Directory.Delete(d); } }

} CSS:

.divTab{position:relative; top:2px; margin-left:10px;}

.divContent {

-webkit-box-shadow:0px 0px 10px #ddd; -moz-box-shadow:0px 0px 10px #ddd; box-shadow:0px 0px 10px #ddd; }

.divTab a{ text-shadow:1px 1px 5px #999; display:block; float:left; margin-right:5px; border:solid 2px #ddd; padding:0px 10px;

-webkit-border-top-left-radius:5px;

- 25 -

-webkit-border-top-right-radius:5px;

background-color:#eff; color:gray; text-decoration:none; cursor:pointer; }

.divTab a:hover{background-color:#fef;}

.divTab .aCur{ border-bottom:solid 2px white; background-color:white; color:blue; cursor:default; }

.divTab .aCur:hover { background-color:white; } table {

*border-collapse: collapse; /* IE7 and lower */ border-spacing: 0; width: 100%; }

.bordered {

border: solid #ccc 1px; -moz-border-radius: 6px; -webkit-border-radius: 6px; border-radius: 6px;

-webkit-box-shadow: 0 1px 1px #ccc; -moz-box-shadow: 0 1px 1px #ccc; box-shadow: 0 1px 1px #ccc; }

.bordered tr:hover { background: #fbf8e9;

-o-transition: all 0.1s ease-in-out;

- 26 -


【毕业论文】基于HTML5 CSS3的相册设计与实现(6).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:28课毛主席在花山

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: