stringwriter

Is there a TextWriter child class that fires event if text is written?

二次信任 提交于 2020-07-18 21:44:13
问题 I have written a method that accepts a TextWriter as an argument (Usually Console.Out, but not necessarily). When I call this method, some progress info is written to the TextWriter. However, since this method can run a long time, I want to update my UI with some status information. Currently, I am using a StringWriter but it does not have any events. So the first time I get a result from the StringWriter is after the method completed. Now I am searching for a class that inherits from

When should I use Java's StringWriter? [closed]

大憨熊 提交于 2020-01-01 04:39:04
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . What is a Java StringWriter , and when should I use it? I have read the documentation and looked here, but I do not understand when I should use it. 回答1: It is a specialized Writer that writes characters to a StringBuffer , and then we use method like toString() to get the string

Why is DataContractSerializer to StringWriter truncated?

。_饼干妹妹 提交于 2019-12-23 10:59:05
问题 I am using the DataContractSerializer to serialize EF4 objects to xml if there are exceptions. In my debug log i can see want was the data-content when something went wrong. I have two versions of code: one version that serializes to a file and one that serializes to a string using StringWriter . When serializing big items to file i get valid xml of about 16kb. when serializing the same item to string the xml is truncated after 12kb. Any idea what caused the truncation? ... var entity = ....

StringWriter in windows universal app

我们两清 提交于 2019-12-23 05:12:10
问题 I am absolutely new to programming. I'm trying to create a very simple app with three TextBoxes and one final TextBlock. I want to save the input from these three TextBoxes locally so I can read and display it in a TextBlock on the bottom of the page in one string. I have read that the StreamWriter class is what I should be using. I just don't know where to start... There's basically not a lot of code so far really public sealed partial class MainPage : Page { public MainPage() { this

XML StringWriter empty

落花浮王杯 提交于 2019-12-11 05:05:57
问题 I have some XML in a XMLDocument and I want to put it into a StringWriter , but it always becomes empty(?) instead. I've tried inspecting the variables with debug, but I'm still clueless as to what's going on. Here's what I have: XmlDocument xmlInput = new XmlDocument(); /* after this executes, xmlInput has lots of data in it */ xmlInput.LoadXml(...); XslCompiledTransform transform = new XslCompiledTransform(); /* I'm pretty sure Template.xslt is being found and loaded correctly */ transform

Return all attributes of an HtmlElement in Web browser

ⅰ亾dé卋堺 提交于 2019-12-07 01:58:36
问题 I need to get all of the attributes from my webbrowser.currently,I am using GetAttribute() but this way,I need to know the name of the attributes. Imagine I do not know what is in my webbrowser. My C# code: StringWriter strWriter = new StringWriter(); XmlWriter xWriter = XmlWriter.Create(strWriter, new XmlWriterSettings() { Indent = true }); xWriter.WriteStartElement("Items"); foreach (HtmlElement el in webBrowser1.Document.GetElementsByTagName("TEXTAREA")) { xWriter.WriteStartElement("Item")

Return all attributes of an HtmlElement in Web browser

馋奶兔 提交于 2019-12-05 06:46:09
I need to get all of the attributes from my webbrowser.currently,I am using GetAttribute() but this way,I need to know the name of the attributes. Imagine I do not know what is in my webbrowser. My C# code: StringWriter strWriter = new StringWriter(); XmlWriter xWriter = XmlWriter.Create(strWriter, new XmlWriterSettings() { Indent = true }); xWriter.WriteStartElement("Items"); foreach (HtmlElement el in webBrowser1.Document.GetElementsByTagName("TEXTAREA")) { xWriter.WriteStartElement("Item"); xWriter.WriteElementString("GUID", el.Id); xWriter.WriteElementString("Type", el.GetAttribute("type")

C# Compact Framework - OutOfMemoryException with XmlSerializer.Serialize

此生再无相见时 提交于 2019-12-04 16:47:44
I'm trying to serialize a large collection of objects (20,000) objects within the collection. I'm doing this using the following code: XmlSerializer xs = new XmlSerializer(deserialized.GetType()); StringWriter sw; using (sw = new StringWriter()) { xs.Serialize(sw, deserialized); // OutOfMemoryException here } string packet = sw.ToString(); return packet; Is there a better way of doing this, or am I doing something blatantly wrong? It looks like it should work, but CF does have unpredictable limitations. Is xml a requirement? I can't remember trying it with 20k records, but another option might

When should I use Java's StringWriter? [closed]

纵饮孤独 提交于 2019-12-03 12:56:39
Closed . This question needs to be more focused. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it focuses on one problem only by editing this post . What is a Java StringWriter , and when should I use it? I have read the documentation and looked here , but I do not understand when I should use it. It is a specialized Writer that writes characters to a StringBuffer , and then we use method like toString() to get the string result. When StringWriter is used is that you want to write to a string, but the API is expecting a Writer or a

Write chinese characters from one file to another

谁都会走 提交于 2019-12-02 09:07:46
问题 I have a file with Chinese characters text inside, I want to copy those text over to another file. But the file output messes with the chinese characters. Notice that in my code I am using "UTF8" as my encoding already: BufferedReader br = new BufferedReader(new FileReader(inputXml)); StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { sb.append(line); sb.append("\n"); line = br.readLine(); } String everythingUpdate = sb.toString(); Writer out = new