Android Question File.copy, copy is bigger than original...

MitchBu

Active Member
Licensed User
I want to log PDF files used to print, so I did this after creating 1.pdf :

B4X:
    If File.Exists(File.DirInternal, "1.pdf") = True Then
        File.Copy(File.DirInternal,"1.pdf",File.DirDefaultExternal,"Print-" & DateTime.Now & ".pdf")
End If
Original (1.pdf) is 21.91 KB
Copy (Print-1560764371069.pdf) is 39.13 KB

Both seem to be valid pdf documents.

Is there any reason to that size difference ?
 

MitchBu

Active Member
Licensed User
OK. Now I have

B4X:
If File.Exists(File.DirInternal, "1.pdf") = True Then
        Dim f As String = rp.GetSafeDirDefaultExternal("")
        Log("safedir: " & f)
        File.Copy(File.DirInternal,"1.pdf",F,"Printo-" & DateTime.Now & ".pdf")
But yet, the copy remains much bigger than the original.
 

MitchBu

Active Member
Licensed User
B4X:
Log(File.Size(File.DirDefaultExternal,"Print-" & DateTime.Now & ".pdf"))

Result - 0
My question was more of curiosity than anything. Like, for instance, the fact that the copy be bigger than the original could be due to the size of clusters, or something.

Meh..
 

Kiffi

Well-Known Member
Licensed User
@MitchBu : Try this, please

B4X:
Dim SourceFile As String = "1.pdf"
Dim TargetFile As String = "Print-" & DateTime.Now & ".pdf"

If File.Exists(File.DirInternal, SourceFile) = True Then
  File.Copy(File.DirInternal, SourceFile, File.DirDefaultExternal, TargetFile)
  Log("Size of SourceFile: " & File.Size(File.DirInternal, SourceFile))
  Log("Size of TargetFile: " & File.Size(File.DirDefaultExternal, TargetFile))
Else
  Log("SourceFile doesn't exists")
End If
Greetings ... Peter
 

MarkusR

Well-Known Member
Licensed User
i think i have two reason.
the file was not overwritten, delete it first and be sure its gone.
if you look the files at pc, to not trust this virual file system. maybe reboot windows.
 
Top