BinaryWritting sequencially

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thiago777
    New Member
    • May 2007
    • 89

    BinaryWritting sequencially

    Hello,

    I have to proccess big files (around 4GB) and to prevent Out of Memory exceptions I am splitting the file in 256MB blocks. The problem is, as I have to create the file sequencially (block by block), I dont know how to "stick"/"concatenat e" the remaining pieces to the last one (or first processed).

    I have to "add" the rest of the bytes to the file, anyone knows if this is possible? I am using FileStream and BinaryWriter to do it.

    For example, to read I can do this:
    [PHP]
    Dim BInput As New FileStream(File name, FileMode.Open, FileAccess.Read )
    Dim Reader As New BinaryReader(BI nput)
    'then inside a loop with variable k:
    Reader.Read(myd ata, k * Dtblock, Dtblock)
    'loop end[/PHP]

    (where Dtblock is a constant that indicates 256MB.)

    but then I dont know the oposite of the instructions above (to write)

    thanks in advance!
  • thiago777
    New Member
    • May 2007
    • 89

    #2
    Originally posted by thiago777
    Hello,

    I have to proccess big files (around 4GB) and to prevent Out of Memory exceptions I am splitting the file in 256MB blocks. The problem is, as I have to create the file sequencially (block by block), I dont know how to "stick"/"concatenat e" the remaining pieces to the last one (or first processed).

    I have to "add" the rest of the bytes to the file, anyone knows if this is possible? I am using FileStream and BinaryWriter to do it.

    For example, to read I can do this:
    [PHP]
    Dim BInput As New FileStream(File name, FileMode.Open, FileAccess.Read )
    Dim Reader As New BinaryReader(BI nput)
    'then inside a loop with variable k:
    Reader.Read(myd ata, k * Dtblock, Dtblock)
    'loop end[/PHP]

    (where Dtblock is a constant that indicates 256MB.)

    but then I dont know the oposite of the instructions above (to write)

    thanks in advance!
    Would it work like:

    [PHP]Dim BOutput As New FileStream(TxtB oxOutput.Text, FileMode.Append, FileAccess.Writ e)
    Dim Writer As New BinaryWriter(BO utput)
    Writer.Write(bu ffer)[/PHP]

    ??

    Comment

    Working...