I’m just starting to learn ASP.NET. I’m using VWD 2010 Express and am trying to delete a file via delete button in a GridView.
Looking at examples on here and elsewhere, one method seems to be similar to this:
using System.IO;
public void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
string filePath = row.Cells[3].Text;
File.Delete(filePath);
}
Apologies if this is an idiotic noob question, but I’m stuck at the last line, with the error:
'File' does not contain a definition for 'Delete'
I hope this is enough information for someone to point out where I’m going wrong but can post more code if needed.
-EDIT- Solution explorer image added for clarity:

Okay, it seems that
Filemeans something other thanSystem.IO.File. You can make it unambiguous this way:… but you should really work out what
Filemeans without that.If you just write
Fileand hover over it, you should be able to get a bit more information. Perhaps a property with that name?Once you’ve found out where the problem is coming from, you could work out whether to rename it, or use the above way of making it completely unambiguous.