you can write this code into your base class
using System.IO;
public static void DeleteExistFile(string name, string path)
{
if (name != null && File.Exists(path))
{
File.Delete(path);
}
}
You can write the following code In derived class button click event
Protected void Button1_Click(object sender, EventArgs e)
{
string path = "~/Images/"+logo.jpg;
BaseclassName.DeleteExistFile(filename,path);
}
(OR) If you want to single line code with out checking file exits or not, you have written this code
using System.IO;
Protected void Button1_Click(object sender, EventArgs e)
{
File.Delete("~/Images/logo.jpg");
}
using System.IO;
public static void DeleteExistFile(string name, string path)
{
if (name != null && File.Exists(path))
{
File.Delete(path);
}
}
You can write the following code In derived class button click event
Protected void Button1_Click(object sender, EventArgs e)
{
string path = "~/Images/"+logo.jpg;
BaseclassName.DeleteExistFile(filename,path);
}
(OR) If you want to single line code with out checking file exits or not, you have written this code
using System.IO;
Protected void Button1_Click(object sender, EventArgs e)
{
File.Delete("~/Images/logo.jpg");
}
No comments:
Post a Comment