using System;
using System.IO;
using System.Windows.Forms;
public static bool DeleteFile(String FileName, bool pForce, ref String oErrMesg)
{
try
{
if (pForce == false)
{
DialogResult res = MessageBox.Show("Delete",
FileName + " Are you sure you want to delete the file",
MessageBoxButtons.YesNo);
if (res == DialogResult.Yes)
{
File.Delete(FileName);
return true;
}
else
return false;
}
else
{
File.Delete(FileName);
return true;
}
}
catch (System.IO.IOException e)
{
oErrMesg = e.Message;
return false;
}
}