File.Create(Application.StartupPath + "
//AlarmSet.txt");//創建該文件
System.IO.Path.GetFileName(filePath) //返回帶擴展名的文件名
System.IO.Path.GetFileNameWithoutExtension(filePath) //返回不帶擴展名的文件名
System.IO.Path.GetDirectoryName(filePath) //返回文件所在目錄
File.Exists(Application.StartupPath + "
//AlarmSet.txt")
System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(Application.StartupPath + "
//AlarmSet.txt");
MessageBox.Show(info.Exists.ToString());
是不是很簡單,但有時候我們可能對GetFileNameWithoutExtension或GetDirectoryName這樣的函數,感覺比較陌生,以前還總傻傻的自己寫函數實現,原來就一行代碼搞定啊~