I want to delete a file with its name and the containing folder;
when I say name I mean without the extension.
Here is the way I know. (with a little help of you, it will works)
//the extension string doesn't work properly.Here I need your help
string extension = Path.GetExtension(@"C:\Projects_2012\Project_Noam\Files\ProteinPic" + comboBox1.SelectedItem.ToString());
string fileLoc = @"C:\Projects_2012\Project_Noam\Files\ProteinPic\" + comboBox1.SelectedItem.ToString() + extension;
if (File.Exists(fileLoc))
{
File.Delete(fileLoc);
}
You can use Directory.GetFiles and use an
*in place of the extension.