开发者

Is there an efficint .Net Forms control out there that can be used to view and edit large xml (100meg ++)

I am working on an application (C#.Net 2008) that creates some large XML files of about 100megs. I know that ultimatly these files should be kept smaller for efficency but unfortuatly these files need to be continuous (1 file). I would like include the ability to view, edit and save changes t开发者_高级运维o these files after creation but have, so far been unable to find a form control along the lines of a richtextbox or treeview that won't hang on loading these files. I have spent about 3 days now trying different controls and solutions with no success. The closest I've come is using Scintilla and the following

using (TextReader reader = new StreamReader(myFilePath, Encoding.UTF8)) 
{scintillaDocument.Text = reader.ReadToEnd(); } 

This allowed me to load one of the large files but when I tried to refresh the file, I got the OutOfMemory issue again.

I know it can be done - TextPad is a great example, but I'd rather use an embedded control.


This problem comes up again and again with XML; and yes, the bottom line is that you don't really want to have such large XML files.

You can implement a strictly text-based editor yourself, which reads the file in sections (as described above). Aside - if you want to have some kind of treeview-like representation, then I am afraid you are pretty much stuck with reading and parsing the entire file upfront. As you've pointed out, updates will be the trickiest. The general approach would probably be to seek to the section in the file that is being edited, and start overwriting the file from that point on with the newly modified section, and from then on, all the sections that were originally in the file following the "current" section. This will still be slow, but you wouldn't get out of memory exceptions.

.Net provides the XmlTextReader and XmlTextWriter, which work with streams, and do check that the XML is well formed. This might be best way to read and write your XML data.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜