Using System.IO;
1. File Upload
----------
The following points:
HTML section:
<form id= "Form1" runat= "Server" method= "POST" enctype= "Multipart/form-data" >
<input id= "FileUpload" type= "file" runat= "server"/><br/>
Background CS Partial button Event
String strfilefullname = System.IO.Path.GetFileName (this. FileUpLoad.PostedFile.FileName);
This. FileUpLoad.PostedFile.SaveAs (Server.MapPath ("./xmlzip/") + Strfilefullname);
2. File download
----------
ListBox SelectedIndexChanged Event settings Related download connection
protected void lst_DownLoadFileList_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
string strJS = "window.open('xmlzip/";
strJS += this.lst_DownLoadFileList.SelectedItem.Text.Trim();
strJS += "'); return false; ";
this.imgbtn_DownLoadFile.Attributes.Add("onclick", strJS);
}
catch (Exception ex)
{
ex.ToString();
}
}
Or you can change the label of the text value to achieve a click to implement the file download super connection
This. Label1.Text = "<a href=\" xmlzip/a.rar\ ">a.rar</a>"
3. File deletion
---------
string strFilePath = Server.MapPath("../CountryFlowMgr/xmlzip/"+this.lst_DownLoadFileList.SelectedItem.Text.Trim());
if (File.Exists(strFilePath))
{
File.Delete(strFilePath);
if (File.Exists(strFilePath))
{
Response.Write("ok");
}
else
{
Response.Write("ok");
}
}