導航:首頁 > 版本升級 > 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文件刪除相關的資料

熱點內容
一個虛擬主機怎麼建多少網站 瀏覽:825
和家親app為什麼老是掉線 瀏覽:990
兒童編程思維課有什麼用 瀏覽:600
魔百和網路機頂盒怎麼連接電視 瀏覽:611
國產顯示器icc配置文件 瀏覽:52
java編程常見的語法糖有哪些 瀏覽:41
jspmysql選課源碼 瀏覽:877
ipadmini2下載app等待 瀏覽:399
creo工程圖配置文件 瀏覽:699
編程和鋼琴哪個貴 瀏覽:841
移動進銷存app哪個好 瀏覽:600
編程製作游戲什麼原理 瀏覽:97
linux如何查看是否有共享文件夾 瀏覽:264
u盤拷貝文件以後為空 瀏覽:917
快雲主機資料庫連接方法 瀏覽:756
javagsp定位 瀏覽:384
jsp頁面表格導出excel 瀏覽:976
imagetest教程 瀏覽:244
怎樣將一個cad文件包圖紙兼容 瀏覽:898
論文有什麼好的網站 瀏覽:581

友情鏈接