1.qprocess::startdetached("explorer "+ path )2.qdesktopservices::openurl(qurl::fromlocalfile(path));
都可以開啟資料夾但有些不同,
1是實際是啟動乙個程式,只是可以傳引數,所以要指定用什麼開啟,開啟引數是什麼(這裡裡用explorer開啟,引數是路徑)路徑記得換成"\"否則開啟c盤 囧
2.以預設方式開啟指定路徑的東西,也許是乙個路徑,也許是乙個檔案,通過比較你發現2比較好寫也,但很快你會發現發生了悲劇的事情,路徑中當在a資料夾開啟最後乙個b資料夾時,如果a中有乙個和b資料夾同名的 .exe檔案,開啟的竟然是這個.exe.......囧(c:/a/b, a裡有個b.exe)
qdir dir;
dir.mkdir(const qstring &dirname) //當前資料夾生成資料夾
dir.mkpath(const qstring &dirpath) //生成資料夾路徑,無則生,有則返回false
qfile::exists(const qstring &filename) //檔案是否存在
總結:開啟資料夾還是用1吧,安全. 2預設開啟檔案好用.
cmd 開啟檔案與資料夾
word start winword c shortcut shortcutword.doc excel start excel c shortcut shortcutexcel.xls powerpoint start powerpnt c shortcut shortcutppt.ppt pdf...
bat檔案 啟動程式 開啟資料夾
bat檔案 啟動程式 開啟資料夾 不想每次開啟機子繼續上一次的工作時去手工乙個乙個滴開啟程式和開啟資料夾,故想寫乙個bat雙擊解決。1 啟動程式 start download.bat echo off echo 準備啟動thunder。echo 啟動完畢,準備退出。rem 為注釋語句 2 開啟資料夾...
右鍵sublime開啟檔案和資料夾
重灌系統之後,sublime還能用,但是右鍵沒有開啟檔案的選項,右鍵選項是在登錄檔中,位於c盤,所以重灌系統之後會沒有右鍵選項。解決如下 win r,輸入regedit,開啟登錄檔 找到 hkey classes root shell,右擊新建項,命名為open with sublime 這裡的名字...