我有这段代码,我觉得可以清理(我可能是错的),但我想看看是否有人建议我如何将其更改为“更好”
string getExt = Path.GetExtension(DocumentUNCPath.Text);
var convertFileId = Guid.NewGuid();
var convertFilePath = @"c:\temp\" + convertFileId + ".pdf";
if (getExt == ".doc" || getExt == ".docx" || getExt == ".txt" || getExt == ".rtf")
{
WordToPdf(convertFilePath);
}
else if (getExt == ".xlsx" || getExt == ".xls")
{
ExcelToPdf(convertFilePath);
}
else if (getExt == ".jpg" || getExt == ".png" || getExt == ".jpeg" || getExt == ".JPG" || getExt == ".PNG")
{
ImgToPDF(convertFilePath);
}