Jump to content

Peter C

Members
  • Content Count

    4
  • Joined

  • Last visited

Everything posted by Peter C

  1. Peter C

    Copying Directory

    Android 14 Delphi 12 Current I'm trying to copy from TPath.GetPublicPath + '/diary' to TPath.GetSharedDocumentsPath + '/backup'. In the TPath.GetPublicPath + '/diary' I have some txt files that I wish to copy to TPath.GetSharedDocumentsPath + '/backup'. When I execute this code it works perfectly, no issues( takes around 2~3sec depending on how many txt files there are to transfer ). But if I repeat the process, nothing happens. It executes and completes instantly. So I manually deleted all the files in the TPath.GetSharedDocumentsPath + '/backup' Folder to see if this was the case. Executed the code, same result, nothing is copied. So then I restarted the phone. Code executes perfectly and all files copy. Try again and back to square 1. If my App creates another txt file, and then executes said code, only the newly created file copies across! Even if I take the Thread Instance out and replace MyThread.Start with TDirectory.Copy( MASTER_PATH, BACKUP_PATH ) the same issue occurs. Am I missing something here?( Well obviously otherwise......) procedure TSERTEC_DIARY.FormCreate(Sender: TObject); begin MASTER_PATH := TPath.GetPublicPath + '/diary'; ARCHIVE_PATH := MASTER_PATH + '/archive'; BACKUP_PATH := TPath.GetSharedDocumentsPath + '/backup'; end; procedure TMyBackgroundThread.Execute; begin TDirectory.Copy( MASTER_PATH, BACKUP_PATH ); end; procedure TSERTEC_DIARY.lbBACKUPClick(Sender: TObject); var MyThread: TMyBackgroundThread; begin MyThread := TMyBackgroundThread.Create(True); // Create suspended MyThread.FreeOnTerminate := True; // Auto-free thread when done rcPopup.Visible := false; rcPopup.Opacity := 0; if TDirectory.Exists( BACKUP_PATH ) then begin try try ListView1.Opacity := 0.5; bkActivityCircle.Visible := true; bkActivityFloatAni.Enabled := true; MyThread.Start; // Start the background thread except ShowMessage('Incorrect source path or destination path'); end; finally ListView1.Opacity := 1; bkActivityCircle.Visible := false; bkActivityFloatAni.Enabled := false; ShowMessage('Backup Complete...'); end; end else begin try try TDirectory.CreateDirectory( BACKUP_PATH ); except ShowMessage('Unable to create path'); end; finally try try ListView1.Opacity := 0.5; bkActivityCircle.Visible := true; bkActivityFloatAni.Enabled := true; MyThread.Start; // Start the background thread except ShowMessage('Incorrect source path or destination path'); end; finally ListView1.Opacity := 1; bkActivityCircle.Visible := false; bkActivityFloatAni.Enabled := false; ShowMessage('Backup Complete...'); end; end; end; end;
  2. Peter C

    Copying Directory

    I did try the overload version and setting to false. Again if I don't touch the files and I let the App do all the file operations, there is no problem. I then deleted a couple of files. Ran the routine again, no errors. But the files that were deleted did not get replaced. I then restored the deleted files and ran the routine again. This time all the files were updated( Checked timestamp ). Even the restored files were updated. To confirm this I also tried using a file copy routine. Works fine but if I delete a file manually and then repeat the copy process, it throws up a permissions error on the file I just deleted. Soooo...it looks like that the files are being tracked or flagged somewhere that are associated( created, copied, deleted etc) with the App. Just have to remember to not perform any file operations outside of the App. Its a pain but I understand why Google have done this. I then use Dropsync to backup the files to Dropbox.
  3. Peter C

    Copying Directory

    I think this has something to do with deleting the files outside of the App. If I let the App perform all operations then all is ok. But if you delete a file manually, it doesn't like it. Hence all these stupid permissions that Google has applied.
×