private string GetPdfPath(string fname)
{
string path = null;
// Sanitize fileName first
string fileName = SanitizeFileName(fname);
for (int i = 0; i < 100; i++)
{
path = Path.Combine(Path.GetTempPath(), string.Format("{0}-{1}.pdf", fileName, i));
if (!RobustFile.Exists(path))
break;
try
{
RobustFile.Delete(path);
break;
}
catch (Exception)
{
//couldn't delete it? then increment the suffix and try again
}
}
return path;
}