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 8903483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:52:51+00:00 2026-06-15T01:52:51+00:00

All, I have the following Append which I am performing when I am producing

  • 0

All, I have the following Append which I am performing when I am producing a single line for a fixed text file

formattedLine.Append(this.reversePadding ?
                     strData.PadLeft(this.maximumLength) :
                     strData.PadRight(this.maximumLength)); 

This particular exception happens on the PadLeft() where this.maximumLength = 1,073,741,823 [a field length of an NVARCHAR(MAX) gathered from SQL Server]. formattedLine = "101102AA-1" at the time of exception so why is this happening. I should have a maximum allowed length of 2,147,483,647?

I am wondering if https://stackoverflow.com/a/1769472/626442 be the answer here – however, I am managing any memory with the appropriate Dispose() calls on any disposable objects and using block where possible.

Note. This fixed text export is being done on a background thread.

Thanks for your time.

  • 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-15T01:52:52+00:00Added an answer on June 15, 2026 at 1:52 am

    This particular exception happens on the PadLeft() where this.maximumLength = 1,073,741,823

    Right. So you’re trying to create a string with over a billion characters in.

    That’s not going to work, and I very much doubt that it’s what you really want to do.

    Note that each char in .NET is two bytes, and also strings in .NET are null-terminated… and have some other fields beyond the data (the length, for one). That means you’d need at least 2147483652 bytes + object overhead, which pushes you over the 2GB-per-object limit.

    If you’re running on a 64-bit version of Windows, in .NET 4.5, there’s a special app.config setting of <gcAllowVeryLargeObjects> that allows arrays bigger than 2GB. However, I don’t believe that will change your particular use case:

    Using this element in your application configuration file enables arrays that are larger than 2 GB in size, but does not change other limits on object size or array size:

    • The maximum number of elements in an array is UInt32MaxValue.

    • The maximum index in any single dimension is 2,147,483,591 (0x7FFFFFC7) for byte arrays and arrays of single-byte structures, and 2,146,435,071 (0X7FEFFFFF) for other types.

    • The maximum size for strings and other non-array objects is unchanged.

    What would you want to do with such a string after creating it, anyway?

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

Sidebar

Related Questions

I have the following code which is loading an xml file to populate a
I have the following code which I got from http://css-tricks.com/startstop-slider/ I have it all
I have written the following function which finds all divisors of a given natural
I have the following code which should remove all HTML from a part of
I have the following code, which loops to get all images in a table
I have the following code which loads a xml file to populate a dropdown.
I have the following case: All boats have a boat type like shark ,
I have following script that executes all the .reg files in the current directory.
I have following statement for query articles from some sections Article.all(:joins => :sections, :conditions
I have following XML. I was able to remove all namespaces but not able

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.