[問題] CFileFind判斷檔案是否存在...

看板C_and_CPP (C/C++)作者 (1+1≠2)時間13年前 (2012/07/20 22:51), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串1/1
目前有 A.txt、B.txt、C.txt、D.txt四個檔案 使用者可以透過參數自動丟其中一個檔案 但是四個檔案彼此是互斥的, 也就是說在同個目錄下,只能有四個檔案中的其中一個檔案... 假設目錄為C:\\Temp 所以,在根據參數丟檔案進資料夾前, 我需要先去判斷這個資料夾內是否有這其中一個檔案.. 我想使用CFileFind去判斷這個資料夾是否有這四個檔案 但是,CFileFind一次只能判斷一個檔案... 那我要如何判斷同個目錄是否有這四個檔案呢? 麻煩各位大大指點一下 FindFile+||條件結果無法使用... CFileFind FindFile; Cstring FilePath="C:\\Temp\"; if(!FindFile.FindFile(FilePath+"A.txt")||!FindFile.FindFile(FilePath+"B.txt") ||!FindFile.FindFile(FilePath+"B.txt")||!FindFile.FindFile(FilePath+"D.txt")) { if (strOrientation=="0"){ chartfile.Open(FilePath+"A.txt",CFile::modeCreate|CFile::modeNoTruncate,NULL); }else if (strOrientation=="90"){ chartfile.Open(FilePath+"B.txt",CFile::modeCreate|CFile::modeNoTruncate,NULL); }else if (strOrientation=="180"){ chartfile.Open(FilePath+"C.txt",CFile::modeCreate|CFile::modeNoTruncate,NULL); }else if (strOrientation=="270"){ chartfile.Open(FilePath+"D.txt",CFile::modeCreate|CFile::modeNoTruncate,NULL); } chartfile.Close(); } FindFile.Close(); -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.27.242.67

07/21 01:53, , 1F
你有看過CFindFile::FindFile是怎麼用的嗎..不是這樣用
07/21 01:53, 1F

07/21 22:53, , 2F
其實..stdio.h 裡面有 access function 了,還是standard..
07/21 22:53, 2F
文章代碼(AID): #1G2N1ey8 (C_and_CPP)
文章代碼(AID): #1G2N1ey8 (C_and_CPP)