java相册源代码下载 java图片下载功能( 二 )


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]="a href='https://www.04ip.com/post/filesystem.aspx?path="+HttpUtility.UrlEncode(d.FullName,System.Text.Encoding.UTF8)+"'img src='https://www.04ip.com/post/images/folder.gif' //a";
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]="a href='"+url+"' target='_blank'img src='"+url+"'width=100 height=128//a";
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);
}
/// summary
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容 。
/// /summary
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
{
【java相册源代码下载 java图片下载功能】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;ithis.DataList1.Items.Count;i++)
{
if(((CheckBox)this.DataList1.Items[i].FindControl("CheckBox1")).Checked)

推荐阅读