阅读:2009回复:8
救命啦,要死人了
用下面的方法删除文件,总是跳出窗口\"无法访问源文件或磁盘\",我传给fFrom的参数格式用\"D:\\\\aa.txt\"和\"D:\\aa.txt\"都没用
请各位指点 void CFileOperate::OnFileDelete(CString fFrom,HWND hwnd) { char strTitle[]=\"It is copying now\"; SHFILEOPSTRUCT FileOp; FileOp.hwnd = hwnd; FileOp.wFunc = FO_DELETE;//执行文件删除 FileOp.pFrom = fFrom;//原文件路径和文件名 FileOp.pTo = NULL; FileOp.fFlags = FOF_SIMPLEPROGRESS; FileOp.hNameMappings = NULL; FileOp.lpszProgressTitle = strTitle; int nOk = SHFileOperation(&FileOp); if(nOk) MessageBox(NULL,\"failed to delete the file\",NULL,MB_OK); else MessageBox(NULL,\"Succeed to delete the file\",\"succeed\",MB_OK); if(FileOp.fAnyOperationsAborted) MessageBox(NULL,\"failed to delete a running file!!\",NULL,MB_OK); } |
|
沙发#
发布于:2005-05-21 18:05
Address of a buffer to specify one or more source file names.
An additional NULL character must be appended to the end of the final name to indicate the end of pFrom. |
|
|
板凳#
发布于:2005-05-21 18:14
void CFileOperate::OnFileDelete(CString fFrom,HWND hwnd)
{ char *strFile = new char[fForm.GetLength + 1]; strcpy( strFile, fFrom ); strFile[strlen(strFile) + 1] = 0; ... FileOp.pFrom = strFile; ... delete strFile; } |
|
|
地板#
发布于:2005-05-22 09:49
没注意到你用MFC,sorry,应该这样写才符合MFC:
void OnFileDelete(CString fFrom, HWND hwnd) { char *pTmp = fFrom.GetBuffer( fFrom.GetLength( ) + 1 ); pTmp[fFrom.GetLength() + 1] = 0; fFrom.ReleaseBuffer(); ... |
|
|
地下室#
发布于:2005-05-22 13:44
靠,救了你命一条,好歹吱一声啊!
|
|
|
5楼#
发布于:2005-05-23 16:33
不好意思,这几天都上不了网,感谢大大的帮助,接分啦
|
|
6楼#
发布于:2005-05-23 17:18
开个玩笑而已!
以为你会回个 \"吱\"。 ;) [编辑 - 5/23/05 by maqian] |
|
|
7楼#
发布于:2005-05-27 12:12
路过接分
|
|
|
8楼#
发布于:2008-04-10 09:26
嘿嘿 好玩...
|
|