java电子相册代码_求JAVA电子相册代码

展开全部

页面:

filesystem
FileSystemBaner.gif

后退

Width="604">

当前所在位置:

后台代码:

using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.IO;

using System.Drawing;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

namespace WebShop

{

///

/// filesystem 的摘要说明。

///

public class filesystem : System.Web.UI.Page

{

protected System.Web.UI.WebControls.LinkButton LinkButton1;

protected System.Web.UI.WebControls.DataList DataList1;

protected System.Web.UI.WebControls.Button Button3;

protected System.Web.UI.WebControls.Button Button1;

protected System.Web.UI.WebControls.TextBox TextBox1;

protected System.Web.UI.WebControls.Button Button2;

protected System.Web.UI.WebControls.Label Label2;

protected System.Web.UI.WebControls.Label Label1;

protected System.Web.UI.HtmlControls.HtmlInputFile fileFeild1;

private void Page_Load(object sender, System.EventArgs e)

{

if(!IsPostBack)

{

Bind();

}

}

private void Bind()

{

string initpath="";

if(Request["path"]==null)

{

initpath=Server.MapPath("FileSystem");

}

else

{

initpath=Request["path"];

}

this.Label1.Text=initpath;

DataTable dt=new DataTable();

DataColumn dc0=new DataColumn("Image",System.Type.GetType("System.String"));

dt.Columns.Add(dc0);

DataColumn dc1=new DataColumn("Name",System.Type.GetType("System.String"));

dt.Columns.Add(dc1);

DirectoryInfo di=new DirectoryInfo(this.Label1.Text);

DirectoryInfo[] dis=di.GetDirectories();

foreach(DirectoryInfo d in dis)

{

DataRow dr=dt.NewRow();

dr[0]="folder.gif";

dr[1]=d.Name;

dt.Rows.Add(dr);

}

FileInfo[] fis=di.GetFiles();

foreach(FileInfo f in fis)

{

string ex=f.Extension.ToLower();

if(ex==".jpg" || ex==".jpeg" || ex==".gif" || ex==".png" || ex==".bmp")

{

string fullname=f.FullName;

string urlpath=fullname.Substring(fullname.IndexOf("FileSystem"));

string url=HttpUtility.UrlEncode(urlpath,System.Text.Encoding.UTF8);

DataRow dr=dt.NewRow();

dr[0]="%22+url+%22";

dr[1]=f.Name;

dt.Rows.Add(dr);

}

}

this.DataList1.DataSource=dt;

this.DataList1.DataBind();

}

#region Web 窗体设计器生成的代码

override protected void OnInit(EventArgs e)

{

//

// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。

//

InitializeComponent();

base.OnInit(e);

}

///

/// 设计器支持所需的方法 - 不要使用代码编辑器修改

/// 此方法的内容。

///

private void InitializeComponent()

{

this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click);

this.Button3.Click += new System.EventHandler(this.Button3_Click);

this.Button1.Click += new System.EventHandler(this.Button1_Click);

this.Button2.Click += new System.EventHandler(this.Button2_Click);

this.Load += new System.EventHandler(this.Page_Load);

}

#endregion

private void LinkButton1_Click(object sender, System.EventArgs e)

{

string Parent=Directory.GetParent(this.Label1.Text).ToString();

if(Parent.IndexOf("FileSystem")>-1)

{

Response.Redirect("filesystem.aspx?path="+Parent);

}

else

{

return;

}

}

private void Button1_Click(object sender, System.EventArgs e)

{

HttpPostedFile hpf=this.fileFeild1.PostedFile;

string ClientPath=hpf.FileName;

string filename=Path.GetFileName(ClientPath);

string ex=Path.GetExtension(filename);

if(ex==".jpg" || ex==".jpeg" || ex==".gif" || ex==".png" || ex==".bmp")

{

string SavePath=this.Label1.Text+"\\"+filename;

hpf.SaveAs(SavePath);

Bind();

}

else

{

Response.Write(Tools.GetAlertJS("所上传的图片格式不正确!"));

return;

}

}

private void Button2_Click(object sender, System.EventArgs e)

{

string filename=this.TextBox1.Text;

Directory.CreateDirectory(this.Label1.Text+"\\"+filename);

Bind();

}

private void Button3_Click(object sender, System.EventArgs e)

{

for(int i=0;i

{

if(((CheckBox)this.DataList1.Items[i].FindControl("CheckBox1")).Checked)

{

int index=this.DataList1.Items[i].ItemIndex;

string filePath=this.Label1.Text+"\\"+this.DataList1.DataKeys[index].ToString();

if(Directory.Exists(filePath))

{

Directory.Delete(filePath,true);

}

if(File.Exists(filePath))

{

File.Delete(filePath);

}

Bind();

}

}

}

}

}

这个是C#的 你改下 Java的就行

本回答由提问者推荐

2Q==

已赞过

已踩过<

你对这个回答的评价是?

评论

收起

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值