如何从我的班级中获取我的异常以显示为 Windows 错误?
这是我的课:
public class Editcap
{
private string _newFileName;
public void convertFileToLibpcap(string filePath)
{
FileInfo fileInfo = new FileInfo(filePath);
_newFileName = fileInfo.FullName.Replace(fileInfo.Extension, "_new") + ".pcap";
invokeProcess(WiresharkProcesses.Editcap, string.Format("{2}{0}{2} -F libpcap {2}{1}{2}", fileInfo.FullName, _newFileName, "\""));
deleteFile(filePath);
}
private void deleteFile(string filePath)
{
try
{
File.Delete(filePath);
}
catch (Exception e)
{
throw new Exception(e.Message);
}
}
public string getNewFileName()
{
return _newFileName;
}
}
从我的表格:
该函数创建具有不同扩展名的新wireshark文件,并应删除旧文件。如果删除失败,我想在弹出窗口中显示消息错误
Editcap editpcap = new Editcap();
editpcap.convertFileToLibpcap(file.FullName);