Every once in a while, it becomes necessary to delete a file in your code. Here is how you do that:
C# FileInfo TheFile = new FileInfo(MapPath(".") + "\\" + txtFile.Text); if (TheFile.Exists) { File.Delete(MapPath(".") + "\\" + txtFile.Text);
VB Dim TheFile As FileInfo = New FileInfo((MapPath(".") + ("\\" + txtFile.Text))) If TheFile.Exists Then File.Delete((MapPath(".") + ("\\" + txtFile.Text))) End If
All Things DotNet Discussed – Winforms/ASP.Net/SharePoint/WPF
Leave a reply
You must be logged in to post a comment.