我正在构建一个 WinForms 应用程序,它通过SaveFileDialog
.
这是我的代码的相关部分。如何确定路径pcapFile
是否有效且存在?
private void btnBrowse_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialogBrowse = new SaveFileDialog();
saveFileDialogBrowse.Filter = "Pcap file|*.pcap";
saveFileDialogBrowse.Title = "Save an pcap File";
saveFileDialogBrowse.ShowDialog();
pcapFile = saveFileDialogBrowse.FileName; //do whatever you like with the selected filename
if (pcapFile != "")
{
FileInfo fileInfo = new FileInfo(pcapFile);
tbOutputFileName.Text = fileInfo.FullName;
}
}