How to obtain the file size of the merged PDF file?

Q:

We are concatenating pdf files into single PDF file. I am using below
code for this and working fine for me however I need a small help.
Before saving merged file into hard disk I wanted to know the actual
size of the file. Can you please help me to get the size of the file?

For i As Integer = 0 To dsInvicePath.Tables(0).Rows.Count - 1
                invoicePath = dsInvicePath.Tables(0).Rows(i)("URL")
                If File.Exists(invoicePath) Then
                    Dim sourcePDFdoc As PDFDoc = New
PDFDoc(invoicePath)
                    sourcePDFdoc.InitializeSecurityHandler()

                    Dim page_end As PageIterator =
sourcePDFdoc.PageEnd()
                    Dim itr As PageIterator = sourcePDFdoc.PageBegin()
                    Dim arlist As New ArrayList

                    While Not itr.Equals(page_end)
                        arlist.Add(itr.Current())
                        itr.Next()
                    End While

                    Dim arImportPage As ArrayList =
newPDF.ImportPages(arlist)
                    For xM As Integer = 0 To arImportPage.Count - 1
                        newPDF.PagePushBack(arImportPage(xM))
                    Next

                    sourcePDFdoc.Close()
                    sourcePDFdoc.Dispose()
                    bFileToSave = True
                End If
            Next
            newPDF.Save(PDFSaveFilePath,
Doc.SaveOptions.e_remove_unused)

            newPDF.Close()
            newPDF.Dispose()
            PDFNet.Terminate()
---

A:

PDFNet does not know the file size until the file actually saved. After
saving the file to disk you can obtain the file size using standard
.NET API. Another approach is to save the file in memory (e.g. as show
in PDFDocMemory sample) which will directly return you the number of
bytes in the output array.