deletefile(deletefile失败代码5怎么解决)

char dStr[100];//下面这段用来删除当前目录下的a.dll

deletefile(deletefile失败代码5怎么解决)

GetCurrentDirectory(100,dStr);

deletefile(deletefile失败代码5怎么解决)

CString cStr;

cStr.Format(\"%s%s\",dStr,\"\\\\a.dll\");

DeleteFile(cStr);

如果删除指定目录下的a.dll

DeleteFile(\"C:\\\\Windows\\\\a.dll\");

DeleteFileThe DeleteFile function deletes an existing file. BOOL DeleteFile( LPCTSTR lpFileName // file name);ParameterslpFileName [in] Pointer to a null-terminated string that specifies the file to be deleted. Windows NT/2000: In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to nearly 32,000 wide characters, call the Unicode version of the function and prepend \"\\\\?\\\" to the path. For more information, see File Name Conventions. Windows 95/98: This string must not exceed MAX_PATH characters. Return ValuesIf the function succeeds, the return value is nonzero.If the function fails, the return value is zero. To get extended error information, call GetLastError.

在delphi中怎么删除文件

try

deletefile(\'文件路径和文件名\');

except

showmessage(\'error\');

end;

直接删的话,就用上面这段代码,已经考虑到了如果当文件不存在时的情况.

如果是要删除到回收站的话用 SHFileOperation(lPSHFILEOPSTRUCT lpFileOp)//这个api函数deletefile,这是我从程序截得一段代码 FileName:string; fos:TSHFileOpStruct; .... FillChar(fos,SizeOf(fos),0); with fos do begin Wnd:=0; wFunc:=FO_DELETE; pFrom:=PChar(FileName); fFlags:=FOF_ALLOWUNDO or FOF_NOCONFIRMATION; end; ShFileOperation(fos);

c\\c++怎样删除文件夹

方便的办法,你可以使用dos命令,在C++里可以用system调用

比如system(\"RMDIR aaa\");

就是删掉aaa这个目录

dos命令可以在cmd里打help回车查看

//这是用vc的方法:bool MyDeleteFile(char * lpszPath) { SHFILEOPSTRUCT FileOp={0}; FileOp.fFlags = FOF_ALLOWUNDO | //允许放回回收站 FOF_NOCONFIRMATION; //不出现确认对话框 FileOp.pFrom = lpszPath; FileOp.pTo = NULL; //一定要是NULL FileOp.wFunc = FO_DELETE; //删除操作 return SHFileOperation(&FileOp) == 0; } void MyDialog::OnButton3() {// MyDeleteFile(\"d:\\\\PID\\0\\0\"); //删除一个文件夹 MyDeleteFile(\"d:\\\\PID.dsp\\0d:\\\\PID.dsw\\0\\0\"); //删除多个文件}void MyDialog::OnButton3() {// MyDeleteFile(\"d:\\\\PID\\0\\0\"); //删除一个文件夹 MyDeleteFile(\"d:\\\\PID.dsp\\0d:\\\\PID.dsw\\0\\0\"); //删除多个文件}