Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7960113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:40:37+00:00 2026-06-04T04:40:37+00:00

Background: I’m fairly new to C# and currently working on a project intended primarily

  • 0

Background:

I’m fairly new to C# and currently working on a project intended primarily for learning. I am creating a library to work with .PAK files, as used by Quake and Quake II. I can read and extract them fine, as well as writing a blank archive, and I’m on to writing data to the archive.

The basic specification can be found here for reference: http://debian.fmi.uni-sofia.bg/~sergei/cgsr/docs/pak.txt

Issue:

I would like to seek to the end of the binary data portion and insert data from a given file. I use BinaryWriter in the method when creating an empty file, so this is what I’m looking to use for insertion. From what I found, seeking and writing with BinaryWriter will write at a given position and overwrite existing data.

My goal is to simply insert data at a given point without losing any existing data. If this is not possible, I imagine that I will need to extract the entire index containing the individual file information (name, offset, length), add binary data, then append the index and append information for the file I am writing.

Any thoughts or suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:40:38+00:00Added an answer on June 4, 2026 at 4:40 am

    You can’t insert data to a file directly using the C# IO classes. The easiest way would be to either read it into a buffer and manipulate the buffer, or write the first part to a temp file, then insert your new data, and then write the remainder of the file and then rename it.
    Alternatively you can append some data at the end of the file and move everything up to create the right amount of usable space where you want to insert your data.

    Take a look at http://www.codeproject.com/Articles/17716/Insert-Text-into-Existing-Files-in-C-Without-Temp

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background I'm learning Objective-C and Cocoa, and I thought creating simple programs to answer
Background - I am using paramiko to put files on a bunch of remote
Background I am working with a monad built of a stack of transformers one
Background The main application where I work is based heavily on the MUMPS-esque Caché
Background A lot of work has gone into optimizing database design, especially in the
Background We currently use OpenID for authentication of users, and use the Claimed Identity
Background info: We are currently 3 web programmers (good, real-life friends, no distrust issues).
Background I graduated 6 months ago, and my collaborative work in college has all
Background of issue: I have a folder with lots of directories, files, attachments, and
Background I once wrote this method: private <T> SortedSet<T> createSortedSet() { return new TreeSet<T>();

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.