I am trying to create a .json file using the C# create functions, but it doesn't want to delete the old file
try
{
    if (File.Exists(filePath))
    {
        File.Delete(filePath);
    }
    using (FileStream fs = File.Create(filePath))
    {
         Byte[] info = new UTF8Encoding(true).GetBytes(result);
         fs.Write(info, 0, info.Length);
    }
}
catch (Exception ex)
{
    LotNumberSearchResult.Text = ex.ToString() + " ---Error while writing";
}
The catch doesn't return anything either.
 
     
    