導航:首頁 > 版本升級 > delphi文件刪除

delphi文件刪除

發布時間:2021-02-25 20:10:24

1. 用delphi如何一次刪除某個目錄下的所有文件

Deletefiles能一次刪除多個文件?我怎麼只能刪除一個

2. DELPHI 如何 刪除一個文件,如:C:\1.txt文件

if FileExists('C:\1.txt') then
DeleteFile('C:\1.txt')
else
ShowMessage('找不到文件');

3. delphi如何刪除文件夾

例:DeleteFile('C:aaabb.dat');

搞錯了,這是刪除文件。我的回答裡面回答過別人的同樣問題,你找一下。

找到了

裡面有。

4. 用DELPHI如何實現:刪除指定目錄(含子目錄)下指定文件名的文件

Function Dir_Del_EX(Const aPath: String): Boolean; //uses ShellAPI 刪除一個目錄:包括非空目錄,內 或者文件容
Var
FO: TSHFILEOPSTRUCT;
aDir: String;
Begin
aDir := ExcludeTrailingPathDelimiter(aPath);
FillChar(FO, SizeOf(FO), 0);
With FO Do
Begin
Wnd := 0;
wFunc := FO_DELETE;
pFrom := PChar(aDir + #0);
pTo := #0#0;
fFlags := FOF_NOCONFIRMATION + FOF_SILENT;
End;
Result := (SHFileOperation(FO) = 0);
End;

5. delphi 怎麼刪除正在使用中的文件

使用CreateFile函數來來判斷文件是否自打開,編寫以下函數就可以判斷文件是否已打開了,代碼如下:
function IsFileInUse(AName: string): boolean;
var
hFileRes: HFILE;
begin
Result := False;
if not FileExists(AName) then exit;

6. delphi怎麼刪除文件夾

ShellExecute( 0, nil, 'cmd.exe', '/c rd 目錄名 /s /q', nil, SW_HIDE );
想知道成不成功,可以用回DirectoryExists('目錄名') 來判答斷

7. delphi 刪除exe所在的文件夾

創建文件夾可以用forcedirectories函數,可以創建深層文件夾;刪除文件夾,可以用到下面的函數,參數為文件夾的路徑,如:d:\show
uses
shellapi;
function
deletedirectory(p
:string):
boolean;
var
f:
tshfileopstruct;
begin
fillchar(f,
sizeof(f),
0);
with
f
do
begin
wnd
:=
0;
wfunc
:=
fo_delete;
pfrom
:=
pchar(p+#0);
pto
:=
pchar(p+#0);
fflags
:=
fof_allowundo+fof_noconfirmation+fof_noerrorui;
end;
result
:=
(shfileoperation(f)
=
0);
end;
要簡單一點的可以用winexec調用dos的rd命令,如;winexec('cmd
/c
rd
/s
/q
d:\show',sw_hide)就一句代碼
遇到con文件夾可以先用winexec('cmd
/c
rd
/s
/q
d:\show\con\',sw_hide)把con文件夾刪除,再用winexec('cmd
/c
rd
/s
/q
d:\show',sw_hide)把show刪除

8. delphi如何刪除目錄和目錄下的所有文件

使用遞歸調用。深入文件夾中刪掉文件,然後再刪文件夾,然後再逐層返回。

function DeleteFile(mDirName: string; Ext: String = '*'): Boolean;
var
vSearchRec: TSearchRec;
vPathName, tmpExt: string;
K: Integer;
begin
Result := true;
tmpExt := Ext;
if Pos('.', tmpExt) = 0 then
tmpExt := '.' + tmpExt;

vPathName := mDirName + '\*.*';
K := FindFirst(vPathName, faAnyFile, vSearchRec);
while K = 0 do
begin
if (vSearchRec.Attr and faDirectory > 0) and
(Pos(vSearchRec.Name, '..') = 0) then
begin
FileSetAttr(mDirName + '\' + vSearchRec.Name, faDirectory);
Result := DeletePath(mDirName + '\' + vSearchRec.Name, Ext);
end
else if Pos(vSearchRec.Name, '..') = 0 then
begin
FileSetAttr(mDirName + '\' + vSearchRec.Name, 0);
if ((CompareText(tmpExt, ExtractFileExt(vSearchRec.Name)) = 0) or (CompareText(tmpExt, '.*') = 0)) then
Result := DeleteFile(PChar(mDirName + '\' + vSearchRec.Name));
end;
if not Result then
Break;
K := FindNext(vSearchRec);
end;
FindClose(vSearchRec);
end;

9. delphi怎樣刪除文件,如刪除c:\123.txt怎麼寫

這是個相對簡單的方法,不知道能不能幫到你
刪除:
procere TForm1.Button1Click(Sender: TObject);
begin
deletefile('c:\123.txt');
end;
復制:
procere TForm1.Button1Click(Sender: TObject);
begin
file('c:\123.txt','d:\123.txt',false); //第一個參數是你要復制的文件,第二個是復制到哪
// 個目錄下,false是 如果存在,則覆蓋
end;

剪切的話,可以把兩段代碼合並,先復制、再刪除

10. delphi中文件的數據刪除怎麼寫

if edit15.Text='' then
begin
showmessage('你還沒有選擇數據');
exit;
end;
if adoquery1.Locate('ck_into',edit15.Text,[])=true then
begin
if messagedlg('確定要刪除!專',mtconfirmation,[mbyes,mbno],0)=mryes then
adoquery1.delete;
end
else
showmessage('數據不存在屬');

閱讀全文

與delphi文件刪除相關的資料

熱點內容
網路通信科目有哪些 瀏覽:942
有個女同藍頭發短發的電影叫什麼 瀏覽:697
appleshuffle紅色是4s耳機 瀏覽:60
日本生化女的電影 瀏覽:165
國產圖片視頻 瀏覽:479
oracle大數據瓶頸 瀏覽:576
法國啄木鳥電影名稱 瀏覽:630
蘋果11網路鎖怎麼解 瀏覽:276
城市大數據分析 瀏覽:291
法國電影一個男的兩個女的 瀏覽:212
妹妹和姐姐電影 瀏覽:999
linux串口後台運行 瀏覽:113
維語紅色電影 瀏覽:213
錢勝成都大數據 瀏覽:786
主角穿越多個現實位面的小說 瀏覽:578
java查詢access資料庫 瀏覽:438
一顆種子長上天的電影 瀏覽:846
手機壓縮文件圖標和別人發的不同 瀏覽:226
徹底刪除cad2016殘留文件 瀏覽:255
大數據時代語文教學設計 瀏覽:277

友情鏈接