//------------------------------------------------- |
03 | //------------------------------------------------- |
04 | void CVideoDemoDlg::Copy_file() |
12 | SetCurrentDirectory( "D:\\" ); |
13 | GetCurrentDirectory(200,path); |
15 | BOOL bWorking
= finder.FindFile( "*.*" ); |
18 | bWorking
= finder.FindNextFile(); |
20 | CString
filename= finder.GetFileName(); |
22 | if (filename==savanewfilename
|| filename == "." ||
filename == ".." ||
filename == "Recycled" ||
filename == "System
Volume Information" ) |
27 | strSrcPath
=strSrcPath + filename; |
28 | CopyDirectory(strSrcPath,strDesPath); |
01 | //------------------------------------------------- |
03 | //------------------------------------------------- |
04 | void CVideoDemoDlg::CopyDirectory(CString
pTo,CString pFrom) |
09 | memset (buf,0, sizeof (buf)); |
10 | memset (buf1,0, sizeof (buf1)); |
11 | memset (&fo,0, sizeof (fo)); |
15 | //复制是FO_COPY,删除是FO_DELETE;
移动FO_MOVE |
18 | fo.fFlags=FOF_NOERRORUI|FOF_NOCONFIRMMKDIR
| FOF_NOCONFIRMATION; |
21 | //------------------------------------------------- |
23 | //------------------------------------------------- |
24 | void CVideoDemoDlg::Delete_file() |
27 | SetCurrentDirectory( "D:\\" ); |
29 | GetCurrentDirectory(200,path); |
32 | BOOL bWorking
= finder.FindFile( "*.*" ); |
35 | bWorking
= finder.FindNextFile(); |
36 | CString
filename= finder.GetFileName(); |
38 | if (filename==savanewfilename
|| filename == "." ||
filename == ".." ||
filename == "Recycled" ||
filename == "System
Volume Information" ) |
40 | //如果是当前在存储的文件夹或根目录或上及目录以及磁盘回收站则不人任何处理 |
44 | DeleteDirectory(filename); |
49 | //------------------------------------------------- |
51 | //------------------------------------------------- |
52 | BOOL CVideoDemoDlg::DeleteDirectory( LPCTSTR DirName) |
55 | char tempFileFind[200]; |
56 | sprintf (tempFileFind, "%s\\*.*
" ,DirName); |
57 | BOOL IsFinded=( BOOL )tempFind.FindFile(tempFileFind); |
61 | IsFinded=( BOOL )tempFind.FindNextFile(); |
63 | if (tempFileFind
== str) |
65 | //如果等于当前正在存储的文件夹就不进行任保操作 |
69 | char foundFileName[200]; |
70 | strcpy (foundFileName,tempFind.GetFileName().GetBuffer(200)); |
71 | if (tempFind.IsDirectory()) |
74 | sprintf (tempDir, "%s\\%s
" ,DirName,foundFileName); |
75 | DeleteDirectory(tempDir); |
80 | char tempFileName[200]; |
81 | sprintf (tempFileName, "%s\\%s
" ,DirName,foundFileName); |
82 | DeleteFile(tempFileName); |
89 | RemoveDirectory(DirName); |
1 | 以上代码是用于文件复制和删除,但是其特殊性,是由其需求确认,正在写的当前文件不能复制和删除 |
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理