![]() |
|
|
|||||||
| Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
![]() |
|
|
Опции темы | Поиск в этой теме | Опции просмотра |
|
#1
|
|||
|
|||
|
... помогите организовать, очень полезная вещь будет
![]() надо с диска D:\ все файлы на C:\ перегнать |
|
#2
|
||||
|
||||
|
Цитата:
Код:
procedure TForm1.Button1Click(Sender: TObject);
var
OpStruc: TSHFileOpStruct;
frombuf, tobuf: array [0..128] of Char;
begin
FillChar( frombuf, Sizeof(frombuf), 0 );
FillChar( tobuf, Sizeof(tobuf), 0 );
StrPCopy( frombuf, 'c:\1\*.*' );
StrPCopy( tobuf, 'c:\2' );
with OpStruc do
begin
Wnd:= Handle;
wFunc:= FO_COPY;
pFrom:= @frombuf;
pTo:=@tobuf;
fFlags:= FOF_NOCONFIRMATION or FOF_RENAMEONCOLLISION;
fAnyOperationsAborted:= False;
hNameMappings:= nil;
lpszProgressTitle:= nil;
end;
ShFileOperation( OpStruc );
end;
|
|
#3
|
|||
|
|||
|
[Error] Unit1.pas(28): Undeclared identifier: 'TSHFileOpStruct'
[Error] Unit1.pas(37): Undeclared identifier: 'Wnd' [Error] Unit1.pas(38): Undeclared identifier: 'wFunc' [Error] Unit1.pas(39): Undeclared identifier: 'pFrom' [Error] Unit1.pas(40): Undeclared identifier: 'pTo' [Error] Unit1.pas(41): Undeclared identifier: 'fFlags' [Error] Unit1.pas(41): Undeclared identifier: 'FOF_RENAMEONCOLLISION' [Warning] Unit1.pas(41): Combining signed and unsigned types - widened both operands [Error] Unit1.pas(42): Undeclared identifier: 'fAnyOperationsAborted' [Error] Unit1.pas(43): Undeclared identifier: 'hNameMappings' [Error] Unit1.pas(44): Undeclared identifier: 'lpszProgressTitle' [Error] Unit1.pas(46): Undeclared identifier: 'ShFileOperation' [Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas' |
|
#4
|
||||
|
||||
|
Попробуйте такой вариант:
Код:
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
{............}
private
{ Private declarations }
public
{ Public declarations }
end;
procedure FileCopy(const SourceFileName, TargetFileName: string);
var
{................}
implementation
{$R *.DFM}
procedure FileCopy(const SourceFileName, TargetFileName: string);
var
S, T : TFileStream;
begin
S := TFileStream.Create(sourcefilename, fmOpenRead );
try
T := TFileStream.Create(targetfilename, fmOpenWrite or fmCreate);
try
T.CopyFrom(S, S.Size ) ;
FileSetDate(T.Handle, FileGetDate(S.Handle));
finally
T.Free;
end;
finally
S.Free;
end;
end;
filecopy('c:\folder','d:\folder2');
|
|
#5
|
|||
|
|||
|
чот я не пойму так чтоли
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, sButton;
type
TForm1 = class(TForm)
sButton1: TsButton;
procedure sButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
private
{ Private declarations }
public
{ Public declarations }
end;
procedure FileCopy(const SourceFileName, TargetFileName: string);
implementation
{$R *.DFM}
procedure FileCopy(const SourceFileName, TargetFileName: string);
var
S, T : TFileStream;
begin
S := TFileStream.Create(sourcefilename, fmOpenRead );
try
T := TFileStream.Create(targetfilename, fmOpenWrite or fmCreate);
try
T.CopyFrom(S, S.Size ) ;
FileSetDate(T.Handle, FileGetDate(S.Handle));
finally
T.Free;
end;
finally
S.Free;
end;
end;
procedure TForm1.sButton1Click(Sender: TObject);
begin
filecopy('c:\folder','d:\folder2');
end;
end.Admin: Читаем правила форума по офрормлению кода, иначе последуют санкции. Последний раз редактировалось Admin, 23.03.2008 в 14:03. |
|
#6
|
||||
|
||||
|
Нет, у вас 2 раза объявляется Private и Public. Правильный вариант внизу
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, sButton;
type
TForm1 = class(TForm)
sButton1: TsButton;
procedure sButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
procedure FileCopy(const SourceFileName, TargetFileName: string);
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure FileCopy(const SourceFileName, TargetFileName: string);
var
S, T : TFileStream;
begin
S := TFileStream.Create(sourcefilename, fmOpenRead );
try
T := TFileStream.Create(targetfilename, fmOpenWrite or fmCreate);
try
T.CopyFrom(S, S.Size ) ;
FileSetDate(T.Handle, FileGetDate(S.Handle));
finally
T.Free;
end;
finally
S.Free;
end;
end;
procedure TForm1.sButton1Click(Sender: TObject);
begin
filecopy('c:\folder','d:\folder2');
end;
end. |
|
#7
|
|||
|
|||
|
откомпилировал но по нажатии на кнопку ничего не копируется...
|
|
#8
|
||||
|
||||
|
Цитата:
Нашел еще одну опечатку, замените название sButton1Click на Button1Click procedure TForm1.sButton1Click(Sender: TObject); begin filecopy('c:\folder','d:\folder2'); end; |
|
#9
|
|||
|
|||
|
а у меня AlphaSkins стоит...
|
|
#10
|
|||
|
|||
|
теперь такая ошибка:
нет доступа, и прав для копирования |
|
#11
|
||||
|
||||
|
Попробуй запустить от имени администратора.
|
|
#12
|
|||
|
|||
|
В общем тут команда
filecopy('c:\folder','d:\folder2'); как я понял , запрашивает файл folder(для его копии) которого нет) а как папку или диск копировать, я тоже не могу найти команды( |
|
#13
|
|||
|
|||
|
нашел исходник от которого можно оттолкнуться)
http://www.delphisources.ru/files/so...drive_info.zip |
|
#14
|
|||
|
|||
|
Цитата:
а на счёт файлов если это вставить \*.* |
|
#15
|
|||
|
|||
|
да я не думал что у делфи возникнут проблемы на перевый взгляд с "лёгкой задачей"
|