Autor Beitrag
Biarchiv
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: Di 19.10.04 16:02 
Hallo,

ich finde keine Lösung zu folgenden Problem.
Ich lasse mir beim Spliten von Dateien diese auf
.001 - .999 aufteilen.

Doch wenn ich diese wieder zusammenbauen will get es nicht. Ich denke ich habe einen Fehler in der DateiExt der das ganze in einer Stringlist einspielt. Der komplette code und procedure ist hier:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
procedure ReuniteFile(FileNames: TStringList; Dir, Ext: string);
var
  I: Integer;
  B: array[0..256] of Byte;
  F, F2: file of Byte;
  NR, NW: Integer;
begin
{$I-}

  if (ExtractFileName(FileNames[0]) = '') or (FileNames.Count = 0) then
    Exit;

  if Dir[Length(Dir)] <> '' then Dir := Dir + '';
  if Ext[1] <> '.' then Ext := '.' + Ext;

  I := Length(ExtractFileExt(FileNames[0]));
  AssignFile(F, Dir +
    ExtractFileName(copy(FileNames[0], 1, Length(FileNames[0]) - I) + Ext));
  Rewrite(F);
  Reset(F);

  try

    for I := 0 to FileNames.Count - 1 do
    begin
      AssignFile(F2, FileNames[I]);
      Reset(F2);

      repeat
        BlockRead(F2, B, SizeOf(B), NR);
        BlockWrite(F, B, NR, NW);
      until Eof(F2);

      CloseFile(F2);
      Application.ProcessMessages;

    end;

  finally
    CloseFile(F);

  end;
{$I+}
end;

begin
var files : TStringList;
f1 : string;
zael : Integer;
begin
If not (ExtractFileExt(Edit1.Text) = '.001') then exit;
  f1 := Edit1.Text;
  zael := 1;
  repeat
  {if FileExists(f1) then }files.Add(f1);
  if length(IntToStr(zael)) = 1 then f1 := ExtractFilename(f1) + '.00' + IntToStr(zael);
//  if files.count > 5 then showmessage('5');
  showmessage(f1);

  if length(IntToStr(zael)) = 2 then f1 := ExtractFilename(f1) + '.0' + IntToStr(zael);
  if length(IntToStr(zael)) = 3 then f1 := ExtractFilename(f1) + '.' + IntToStr(zael);
  f1 := ExtractFilename(f1);
  f1 := ExtractFilePath(Edit1.Text + f1);
  zael := zael + 1;
  until not (Fileexists(f1));

ReuniteFile(files, ExtractFilePath(Edit1.Text), ExtractFileExt(Edit1.Text));
end;


Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt.
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Di 19.10.04 20:48 
Eine genauere Fehlerbeschreibung wäre hilfreich.

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Di 19.10.04 21:18 
Biarchiv hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
  if Dir[Length(Dir)] <> '' then Dir := Dir + '';
  if Ext[1] <> '.' then Ext := '.' + Ext;

1. Was Soll die Dir-Abfrage?
2. IF Ext = '' Then Gibt's ne AV.

3. Bitte Delphi-Tags nutzen.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Biarchiv Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: Mi 20.10.04 08:33 
Hallo,

die dir ist das Verzeichniss der Datei die zusammengefügt werden.

Das Programm soll alle von datei.001 bis .999 (nur wenn die existieren) in der files (TStringlist) reinschreiben.

Er macht garnichts. Die Datei hat plötzlich 2X Ext obwohl eines gelöscht wird.

Die obere procedure habe ich vom Delphi2000 helper.
ist ist nur das untere zwischen
begin
var files : TStringList;

end;
anzusehen.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mi 20.10.04 19:29 
Probier mal die Funktion ChangeFileExt aus.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Biarchiv Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: Fr 22.10.04 15:09 
Hallo,

die hatte ich schon getestet. Da bekomme ich einen Access Error von Windows unter Win2000.