ieleja Posted October 11, 2013 Report Share Posted October 11, 2013 (edited) Windows 7-64, Code::Blocks 10.05atrodot failus ar _findfirst, _findnext, tos neizdodas izdzēst, tiešā veidā (3 priekšpēdējās rindas) failus izdzēškods: #include <fstream> #include <iostream> #include <string> #include <dirent.h> #include <string.h> #include <time.h> #include <unistd.h> #include <sys/stat.h> #include <sys/types.h> int main(void) { struct _finddata_t dirFile; long hFile; char cCurrentPath[FILENAME_MAX]; _getcwd(cCurrentPath, sizeof(cCurrentPath)); printf ("The current working directory is %s\n", cCurrentPath); if ((hFile = _findfirst("*.txt", &dirFile)) != -1) { do { if (remove("dirFile.name") != 0) { perror("Error deleting file"); printf("%s\n", dirFile.name); } else { printf("%s - DEL\n", dirFile.name); } } while (_findnext(hFile, &dirFile) == 0); _findclose(hFile); } remove("abc.txt"); remove("def.txt"); remove("ghi.txt"); return(0); } failu struktūra: dir c:\files Directory of c:\files 2013.10.12. 00:48 <DIR> . 2013.10.12. 00:48 <DIR> .. 2013.10.12. 00:39 0 abc.txt 2013.10.12. 00:40 0 def.txt 2013.10.12. 00:46 478,208 delFiles.exe 2013.10.12. 00:40 0 ghi.txt 4 File(s) 478,208 bytes komandas izvads: C:\files>delFiles.exe The current working directory is C:\files Error deleting file: No such file or directory abc.txt Error deleting file: No such file or directory def.txt Error deleting file: No such file or directory ghi.txt Edited October 11, 2013 by ieleja Quote Link to comment Share on other sites More sharing options...
codez Posted October 12, 2013 Report Share Posted October 12, 2013 izskatās, ka tu mēģini dzēst failu ar nosaukumu "dirFile.name". nomaini: remove("dirFile.name") uz remove(dirFile.name) Quote Link to comment Share on other sites More sharing options...
ieleja Posted October 12, 2013 Author Report Share Posted October 12, 2013 ups! tiešām tā bija tā kļūda, paldies Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.