
deletefile
軟件語(yǔ)言:簡(jiǎn)體中文
|
軟件授權(quán):免費(fèi)軟件
|
適用系統(tǒng):Windows
|
創(chuàng)建時(shí)間:2021-01-12 |
軟件廠商/開(kāi)發(fā)者信息:獨(dú)立開(kāi)發(fā)者
|
錦囊 更多
- deletefile的教程 2021-03-30
- 提升Git體驗(yàn):探索Gitui——高效的終端UI工具 2024-01-05
- Stirling PDF - 強(qiáng)大的本地 PDF 管理工具 2024-01-05
資訊 更多
- 文件定時(shí)刪除工具 deletefile v2.0 綠色版更新 2014-03-25
- 微信Mac插件——微信小助手,是一款功能強(qiáng)大的插件 2024-01-08
- 完美解碼:打造頂級(jí)視聽(tīng)盛宴的終極使用指南 2024-01-06
介紹(MFC)
用法
DeleteFile 方法刪除指定文件。
object.DeleteFile ( filespec[, force] );
參數(shù)
object
必選項(xiàng)。 應(yīng)為 FileSystemObject 的名稱(chēng)。
filespec
必選項(xiàng)。 要?jiǎng)h除的文件的名稱(chēng)。filespec可以在最后的路徑成分中包含通配字符。
force
可選項(xiàng)。 Boolean 值,如果要?jiǎng)h除設(shè)置了只讀屬性的文件,則為true;如果不刪除則為false(默認(rèn))。
介紹(VC)
刪除一個(gè)存在的文件。
用法
DeleteFile 方法刪除指定文件。
BOOL DeleteFile(
LPCSTRlpFileName//要?jiǎng)h除的文件名的指針
);
參數(shù)
lpFileName
必選項(xiàng)。要?jiǎng)h除文件的路徑。
返回值
成功返回非零,失敗返回0
更多錯(cuò)誤信息使用GetLastError獲取。
如果程序嘗試刪除一個(gè)不存在的文件。GetLastError返回ERROR_FILE_NOT_FOUND。如果文件是只讀 的,則GetLastError返回ERROR_ACCESS_DENIED
注:
在2000/NT/XP系統(tǒng)下,如果程序試圖去刪除一個(gè)輸入輸出文件或者是內(nèi)存映射文件函數(shù)調(diào)用就會(huì)失敗
說(shuō)明
如果找不到匹配的文件則出錯(cuò)。DeleteFile方法在遇到第一個(gè)錯(cuò)誤時(shí)終止。 出錯(cuò)后不試圖回滾或撤消出錯(cuò)前做的修改。
MFC示例
CString type,dPath;
dPath.Format("%s\\Log\\",SystemDir); //指定路徑
BOOL ret=0;
CFileFind tempFind;
CString foundFileName,tempFileName;
CString tempFileFind=dPath+_T("*.*");
BOOL IsFinded=(BOOL)tempFind.FindFile(tempFileFind);
while(IsFinded)
{
IsFinded=(BOOL)tempFind.FindNextFile();
if(!tempFind.IsDots())
{
foundFileName=tempFind.GetFileName();
tempFileName=dPath+foundFileName;
ret = DeleteFile(tempFileName); // 刪除文件
}
}
tempFind.Close();
VC示例
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
TCHAR ch;
BOOL b = DeleteFile("D:\\1.txt");
if(!b)
{
DWORD d = GetLastError();
sprintf(ch,"刪除失??!錯(cuò)誤代碼:%d",d);
MessageBox(NULL,ch,"刪除文件失??!",MB_OK | MB_ICONERROR);
return 0;
}
MessageBox(NULL,"刪除文件成功","刪除文件成功!",MB_OK);
return 0;
}
在C#中使用
導(dǎo)入庫(kù):kernel32.dll
***.Net中運(yùn)用
命名空間 using System.Runtime.InteropServices;
導(dǎo)入庫(kù) [DllImport("kernel32.dll", EntryPoint = "DeleteFile")]
函數(shù)原型 public static extern bool DeleteFile(StringBuilder path);
參數(shù)說(shuō)明 StringBuilder path,path指的是所要?jiǎng)h除文件的絕對(duì)路徑
返回值 布爾值
版本列表
-
-
-
文件定時(shí)刪除工具 deletefile v2.0 綠色版
deletefile是一個(gè)文件定時(shí)刪除工具,可以用此參數(shù)刪除指定文件。修改配置文件c ...
軟件大小:625.03 KB 更新時(shí)間:2014-03-25
-