Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2002.10.03;
Скачать: CL | DM;

Вниз

Копиование перемещение файлов не получается :( pls help   Найти похожие ветки 

 
Игорь ©   (2002-08-09 04:12) [0]

Никак не могу заставить работать APIшные функции копирования файлов, кинньте если не западло работоспособный участок кода, или ссылку на него.


 
MBo ©   (2002-08-09 06:34) [1]

а в FAQ?


 
MARcoDEN ©   (2002-08-09 08:12) [2]

Copyfile("C:\1.txt","C:\files\2.txt",0);

где первый параметр - путь и имя нужного файла, а второй путь и имя нового(скопированого) файла


 
stany ©   (2002-08-17 20:26) [3]

interface

uses Windows;

function DeleteFiles( Handle : HWnd; Names : array of string; ToRecycle : Boolean ) : Integer;
function CopyFiles( Handle : HWnd; Src : array of string; Dest : string; Move : Boolean; AutoRename : Boolean ) : Integer;
function RenameFiles( Handle : HWnd; Src : string; New : string; AutoRename : Boolean ) : Integer;

implementation

uses ShellAPI;

type TBuffer = array of Char;

procedure CreateBuffer( Names : array of string; var P : TBuffer );
var
I, J, L : Integer;
begin
for I := Low( Names ) to High( Names ) do
begin
L := Length( P );
SetLength( P, L + Length( Names[ I ] ) + 1 );
for J := 0 to Length( Names[ I ] ) - 1 do
P[ L + J ] := Names[ I, J + 1 ];
P[ L + J ] := #0;
end;
SetLength( P, Length( P ) + 1 );
P[ Length( P ) ] := #0;
end;

function DeleteFiles( Handle : HWnd; Names : array of string; ToRecycle : Boolean ) : Integer;
var
SHFileOpStruct : TSHFileOpStruct;
Src : TBuffer;
begin
CreateBuffer( Names, Src );
with SHFileOpStruct do
begin
Wnd := Handle;
wFunc := FO_DELETE;
pFrom := Pointer( Src );
pTo := nil;
fFlags := 0;
if ToRecycle then fFlags := FOF_ALLOWUNDO;
fAnyOperationsAborted := False;
hNameMappings := nil;
lpszProgressTitle := nil;
end;
Result := SHFileOperation( SHFileOpStruct );
Src := nil;
end;

function CopyFiles( Handle : Hwnd; Src : array of string; Dest : string; Move : Boolean; AutoRename : Boolean ) : Integer;
var
SHFileOpStruct : TSHFileOpStruct;
SrcBuf : TBuffer;
begin
CreateBuffer( Src, SrcBuf );
with SHFileOpStruct do
begin
Wnd := Handle;
wFunc := FO_COPY;
if Move then wFunc := FO_MOVE;
pFrom := Pointer( SrcBuf );
pTo := PChar( Dest );
fFlags := 0;
if AutoRename then fFlags := FOF_RENAMEONCOLLISION;
fAnyOperationsAborted := False;
hNameMappings := nil;
lpszProgressTitle := nil;
end;
Result := SHFileOperation( SHFileOpStruct );
SrcBuf := nil;
end;

function RenameFiles( Handle : HWnd; Src : string; New : string; AutoRename : Boolean ) : Integer;
var SHFileOpStruct : TSHFileOpStruct;
begin
with SHFileOpStruct do
begin
Wnd := Handle;
wFunc := FO_RENAME;
pFrom := PChar( Src );
pTo := PChar( New );
fFlags := 0;
if AutoRename then fFlags := FOF_RENAMEONCOLLISION;
fAnyOperationsAborted := False;
hNameMappings := nil;
lpszProgressTitle := nil;
end;
Result := SHFileOperation( SHFileOpStruct );
end;

end.



 
Игорь ©   (2002-08-18 02:24) [4]

Спасибо народ (особенно stany). Вы будете смеятся но всё дело в том, что я забыл поставить #


 
stany ©   (2002-08-18 02:37) [5]

Бывает...



Страницы: 1 вся ветка

Текущий архив: 2002.10.03;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.016 c
1-8002
grifon
2002-09-21 13:04
2002.10.03
MP3


1-8036
MsGuns
2002-09-22 17:01
2002.10.03
Не создает экземпляр класса TCollection


1-8007
123000
2002-09-21 16:35
2002.10.03
Как включить и выключить комп?


3-7860
REA
2002-09-11 16:52
2002.10.03
BatchMove


3-7836
Best Before 2024
2002-09-12 12:23
2002.10.03
Вложенные транзакции в ADO