streamreader

C# StreamReader save to Array with separator

て烟熏妆下的殇ゞ 提交于 2019-12-20 07:19:13
问题 I´ve got a text file with tabulator separated data. What I need in my C# application is that I read one line from the text file and save them to an array, separate them at the each \t . Then I do the same thing with the next row. My code: StreamReader sr = new StreamReader(dlg.FileName); string s = sr.ReadLine(); Now, I already tried to write the line into an array but that doesn´t work. Does anyone one how to manage this? 回答1: Use the Split method to create an Array of the line string[]

Why am I getting, “Unable to connect to the remote server”?

白昼怎懂夜的黑 提交于 2019-12-20 05:47:22
问题 This err msg is the next one I get after resolving “NotSupportedException” as noted here I don't even reach the break point in the server code (set on the first line of the method that should be getting called). This is the relevant server code: [Route("api/PlatypusItems/PostArgsAndXMLFileAsStr")] public async void PostArgsAndXMLFileAsStr([FromBody] string stringifiedXML, string serialNum, string siteNum) { string beginningInvoiceNum = string.Empty; // <= Breakpoint on this line string

Program Issues Going From Unity To HoloLens - Cannot convert from 'string' to 'System.IO.Stream'

大兔子大兔子 提交于 2019-12-20 02:54:43
问题 I have a program written in Unity using C# that initializes a new StreamReader and proceeds to read the text data from a text file I have stored in Unity's resources folder. Everything works fine when I click play in Unity -everything works and the text is read and displayed perfectly. However, when I try to build it in order to run it via the HoloLens emulator (Platform: Windows Store, SDK: Universal 10, Build and Run On: Local Machine), I get the error: error CS1503: Argument 1: cannot

Moving the file cursor up lines?

折月煮酒 提交于 2019-12-20 02:43:16
问题 I've googled this like crazy, and I can't seem to find any reference at all to this particular type of problem. I have a StreamReader object with a file, and I want to read over a certain number of lines in the file a certain number of times, however, There doesn't seem to be any way to move the file cursor to certain positions in the file. (No code because I have no clue how I would go about writing something like this) 回答1: You should be able to use myStreamReader.BaseStream.Position =

C# Client/Server: using Streamreader/writer

旧巷老猫 提交于 2019-12-19 10:34:14
问题 I'm relatively new to C# but here goes: I am developing a remote file service client/server console application in C# which is supposed to exchange messages using synchronous sockets. One of the main problems (even thought it might seem simple) is to return a string from the server, to the client using streamreader/streamwriter. The application user a command line interface with options (from a switch statement) to execute actions. I.e. typing 1 and enter would execute the code to send the

Execute Process Chain

只愿长相守 提交于 2019-12-19 09:09:26
问题 public void ExecuteProcessChain(string[] asProcesses, string sInRedirect, string sOutRedirect) { Process p1 = new Process(); p1.StartInfo.UseShellExecute = false; p1.StartInfo.RedirectStandardOutput = true; p1.StartInfo.FileName = asProcesses[0]; p1.Start(); StreamReader sr = p1.StandardOutput; string s, xxx = ""; while ((s = sr.ReadLine()) != null) Console.WriteLine("sdfdsfs"); //xxx += s+"\n"; p1.StartInfo.RedirectStandardInput = true; p1.StartInfo.RedirectStandardOutput = false; p1

How to read the Website content in c#?

元气小坏坏 提交于 2019-12-19 06:26:45
问题 I want to read the website text without html tags and headers. i just need the text displayed in the web browser. i don't need like this <html> <body> bla bla </td><td> bla bla <body> <html> i just need the text "bla bla bla bla". I have used the webclient and httpwebrequest methods to get the HTML content and to split the received data but it is not possible because if i change the website the tags may change. So is there any way to get only the displayed text in the website anagrammatically

How to read the Website content in c#?

萝らか妹 提交于 2019-12-19 06:26:03
问题 I want to read the website text without html tags and headers. i just need the text displayed in the web browser. i don't need like this <html> <body> bla bla </td><td> bla bla <body> <html> i just need the text "bla bla bla bla". I have used the webclient and httpwebrequest methods to get the HTML content and to split the received data but it is not possible because if i change the website the tags may change. So is there any way to get only the displayed text in the website anagrammatically

Is StreamReader.Readline() really the fastest method to count lines in a file?

梦想的初衷 提交于 2019-12-18 12:21:59
问题 While looking around for a while I found quite a few discussions on how to figure out the number of lines in a file. For example these three: c# how do I count lines in a textfile Determine the number of lines within a text file How to count lines fast? So, I went ahead and ended up using what seems to be the most efficient (at least memory-wise?) method that I could find: private static int countFileLines(string filePath) { using (StreamReader r = new StreamReader(filePath)) { int i = 0;

StreamReader and reading an XML file

落花浮王杯 提交于 2019-12-17 20:05:37
问题 I get a response from a web-server using StreamReader... now I want to parse this response (it's an XML document file) to get its values, but every time I try to do it I get a error: Root element is missing. If I read the same XML file directly, the file is well formatted and I can read it. This is the stream: WebResponse response = webRequest.GetResponse(); Stream responseStream = response.GetResponseStream(); StreamReader responseReader = new StreamReader(responseStream); string