hi!!! i m written this code for delete pic from folder
take a look of this it should helps you
protected void DelBtn_Click(object sender, EventArgs e)
{
if (ListBox1.SelectedIndex== 0)
{
Itemessage.Visible = true;
Itemessage.Text = "plz select another Image from box it is main pic ..";
return;
}
if( ListBox1.SelectedItem==null)
{
Itemessage.Visible = true;
Itemessage.Text = "plz select Image from box first..";
return;
}
if (ListBox1.SelectedIndex > -1)
{
string _value = ListBox1.SelectedItem.Value;
string _text = ListBox1.SelectedItem.Text;
ListItem item = new ListItem();
item.Text = _text;
item.Value = _value;
string completePath = Server.MapPath("~/ItemsPics/" + item.Text);
if (System.IO.File.Exists(completePath))
{
System.IO.File.Delete(completePath);
}
ListBox1.Items.Remove(item);
searchimg();
}
}