views:

210

answers:

2

Im copying data (text) to a clipboard but the data that I'm copying to the clipboard has a length of 30,500,000. This text is stored in a StringBuilder.

These are may codes:

        StringBuilder sbText = new StringBuilder();

        // Append text to sbText here!!!

        Clipboard.SetDataObject(sbText.ToString()); // In this line sbText.Length is equal to 30,500,000.

After this I tried to paste the data but I can't (no data pasted!!!).

I understand that there is a limit in Clipboard size based on the free RAM of the pc.

Is there a way to copy/paste this much data in clipboard without error? Is there a way to check if the clipboard size is not enough to do this operation?

Please share some light...

+1  A: 

If you're putting 30MB into the Clipboard, you might want to explore other places to store the data. Can you pass it or access it from the other place(s) that need it? Can it be stored in some form of temp location (sql, file, etc) and read/deleted?

tsilb
Sir tsilb,This is the scenario:- For example I have a text box that contains 30,000,000 characters- the user selects all the texts- pressed Ctrl+C- open a notepad and paste it manually.If you are saying that the text copied can be first stored to a temporary file, please teach me...I did not think that the text copied manually can be stored in a temporary file first...
Kuroro
Given this new information, see my other answer. Code doesn't look right in comments.
tsilb
A: 
        string filename = System.IO.Path.GetTempFileName();
        System.IO.File.WriteAllText(filename), "content goes here");
        System.Diagnostics.Process.Start(filename);
        System.IO.File.Delete(filename);
tsilb
Sir tsilb, correct me if my understanding is wrong...1. The user copy manually the all texts (30,000,000) from the textbox.2. All texts copied will be written in a temporary file.3. the temporary will be opened.then what?
Kuroro
Why bother copying to the clipboard? This code saves it to a temp file, opens the file in Notepad (or their default text editor) and deletes the temp file. Should take around one second.
tsilb