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

MitchBu

Well-Known Member
Licensed User
Longtime 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

Well-Known Member
Licensed User
Longtime 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.
 
Upvote 0

MitchBu

Well-Known Member
Licensed User
Longtime 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..
 
Upvote 0

Kiffi

Well-Known Member
Licensed User
Longtime 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
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime 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.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…