I am new to asp.net I have upload file control in .aspx page it works fine. However, I want to delete previous uploaded file from directory if user uploaded a new file.
So this is the abstract code of my code behind file:
public partial class mypage : System.Web.UI.Page
{
//I cannot access upload label control value here
string lblValue = lbluploadFile.Text //this global variable doesn't work
protected void Page_Load(object sender, EventArgs e)
{
// I can access asp.net label control value in page load
lbluploadFile.Text
}
protected void btnAttachment_Click(object sender, EventArgs e)
{
File.Delete(ConfigurationManager.AppSettings["UploadFolder"].ToString() + lblValue);
}
}