Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to divide a file into 1.44 mb volumes Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
27-Jul-03
Category
Files Operation
Language
Delphi 2.x
Views
127
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Güray CELIK

How can i divide a file into 1.44 mb volumes if file size is longer than floppy 
capacity?

Answer:

1   const
2     MaxSize: Longint = 1440000; //byte
3   
4   function ExtractFileNames(FileNames: string): string;
5   var
6     S: string;
7   begin
8     S := '';
9     while Pos('.', FileNames) > 0 do
10    begin
11      S := S + Copy(FileNames, 1, Pos('.', FileNames) - 1);
12      Delete(FileNames, 1, Pos('.', FileNames));
13    end;
14    result := S;
15  end;
16  
17  procedure TForm1.SpeedButton1Click(Sender: TObject);
18  var
19    InFile, OutFile: file;
20    CopyBuffer: POINTER; { buffer for copying }
21    iRecsOK, iRecsWr, index: Integer;
22    sFileName, sFileExt, sFileFullName: string;
23    fFileSize: file of Byte;
24    Size: LongInt;
25  begin
26    sFileFullName := 'C:\1\1.mp3';
27    sFileName := ExtractFileName(sFileFullName);
28    sFileExt := ExtractFileExt(sFileName);
29    sFileName := ExtractFileNames(sFileName);
30  
31    ShowMessage(sFileFullName + #13 + sFilename + #13 + sFileExt);
32  
33    if FileExists(sFileFullName) then
34    begin
35      AssignFile(fFileSize, sFileFullName);
36      FileMode := 0; {Set file access to read only }
37      Reset(fFileSize);
38      Size := FileSize(fFileSize); {Get File Size}
39      CloseFile(fFileSize);
40      ShowMessage(IntToStr(Size));
41  
42      if Size > MaxSize then
43      begin {Divide}
44        Getmem(CopyBuffer, MaxSize); { allocate the buffer }
45  
46        Assignfile(inFile, sFileFullName); //+ '.ZIP');
47        Reset(inFile, 1);
48  
49        index := 1;
50        repeat
51          AssignFile(outFile, sFileName + '-' + IntToStr(index) + sFileExt);
52          Rewrite(OutFile, 1);
53          inc(index);
54          BlockRead(InFile, CopyBuffer^, MaxSize, iRecsOK);
55          BlockWrite(OutFile, CopyBuffer^, iRecsOK, iRecsWr);
56          CloseFile(OutFile);
57        until (iRecsOK < MaxSize);
58        CloseFile(InFile);
59        FreeMem(CopyBuffer, MaxSize); { free the buffer }
60        ShowMessage('Done..!');
61  
62      end
63      else
64      begin
65        ShowMessage('Do nothing..!');
66      end;
67    end
68    else
69      ShowMessage('File: ' + sFileFullName + ' not found');
70  end;


If you can put it back, you can use DOS copy function; 

copy /b file-1.xxx+file-2.xxx+file-3.xxx file.mp3 

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC