This error simply means that your application or any other application has already opened the file. You would want to check if you really closed all handles of this file before trying to delete it. If you would show us some code we might be able to give you a better advice.
Updated answer after comment:
You are trying to delete the file after you created it. You said you want to check if it already exists and then delete it. So, this is how it's done:
string path = Application.StartupPath + "\\PurchaseBill.xml";
if (File.Exists(path))
File.Delete(path);
using(XmlWriter writer = XmlWriter.Create(path))
{
writer = XmlWriter.Create(path); writer.WriteStartElement("Bill");
writer.WriteElementString("VoucherNo", dtHeaderInfo.Rows[0][0].ToString());
writer.WriteElementString("VoucherType", dtHeaderInfo.Rows[0][1].ToString());
writer.WriteElementString("VoucherDate", dtHeaderInfo.Rows[0][2].ToString());
writer.WriteElementString("PartyId", dtHeaderInfo.Rows[0][3].ToString());
writer.WriteElementString("BillNo", dtHeaderInfo.Rows[0][4].ToString());
writer.WriteElementString("BillDate", dtHeaderInfo.Rows[0][5].ToString());
writer.WriteEndElement();
writer.Flush();
}