Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Copying A Fille U/ Dynamic Array

Featured Replies

Posted

a very simple procedure (add to private declaration unless other units need access to it) that'll read and write 1 byte each time using "for" loop to the file size, just look and read comments.

This supports a progress bar for user interface ;]

procedure TMainForm.Copy_File(Source, Dest: PChar; ProgressBar: TProgressBar);
var
MyArray: Array Of Byte; //Dynamic Array Of Byte
hRead, hWrite: THandle; //Handles returned by CreateFile, usage for Reading file size and writing the new file lpNumberOfBytesWritten: Cardinal; //Store how many bytes have been written
lpNumberOfBytesReaded: Cardinal; //Store how many bytes have been readed nFileSize: Integer; //Stores the size of the file to be copied
i: Integer; //Temp variable for the use of "for" loop
begin
hRead := CreateFile(source, GENERIC_READ, 0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); //Open the file with GENERIC_READ access
nFileSize := GetFileSize( hRead, nil ); //Reads the file size
ProgressBar.Max := nFileSize; //We set the maximum position of the progressbar according to the file size (int)
SetLength( MyArray, nFileSize ); //Set the size of the dynamic array within file size (bytes)
hWrite := CreateFile(dest, GENERIC_WRITE, 0, nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);for i := 0 to nFileSize-1 do
begin
Application.ProcessMessages;
ProgressBar.Position := i;
ReadFile( hRead, MyArray[i], sizeof(MyArray[i]), lpNumberOfBytesReaded, nil);
WriteFile( hWrite, MyArray[i], sizeof(MyArray[i]), lpNumberOfBytesWritten, nil);
end;//Cleanup routine...
Progressbar1.Position := 0;
//Close handles when done using them (so other programs can have access, unless you use SHARED_ACCESS)
CloseHandle( hRead );
CloseHandle( hWrite );
end;

Edited by Rot1

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.