streamreader

How do I open an already opened file with a .net StreamReader?

I have some .csv files which I'm using as part of a test bench. I can open them and read them without any problems unless I've already got the file open in Excel in which case I get an IOException: System.IO.IOException : The process cannot access the file 'TestData.csv' because it is being used by another process. This is a snippe...

C# HTTPWebResponse + StreamReader Very Slow!!!

Hi all. I'm trying to implement a limited web crawler in C# (for a few hundred sites only) using HttpWebResponse.GetResponse() and Streamreader.ReadToEnd() , also tried using StreamReader.Read() and a loop to build my HTML string. I'm only downloading pages which are about 5-10K. It's all very slow! For example, the average GetRespons...

Does disposing streamreader close the stream?

I am sending a stream to methods to write on, and in those methods I am using a binary reader/wrtier. When the reader/writer gets disposed, either by using or just when it is not referenced, is the stream closed as well?? I would send a BinaryReader/Writer, but I am using a StreamReader too (maybe I should go around that. I am only usin...

read an xml stream

Hi. I am trying to read the following xml stream but am really struggling. <channelSnapshot xmlns="urn:betfair:games:api:v1"> <channel gameType="BLACKJACK" id="1444077" name="Exchange BlackJack"> <status>RUNNING</status> <game id="190675"> <round>1</round> <bettingWindowTime>30</bettingWindowTime> <bettingWindowPercentageComplete>100</b...

How to read each line in a file which is delimited by LF only?

I have to read line-by-line a log file. It's about 6MB in size and 40000 line total. But after testing my program, I discover that that log file is only delimited by LF character only. So I can't use the Readline method of StreamReader class How can I fix this problem? edit: I tried to use Text Reader, but my program still didn't work:...

CSV File read. Special Chars problem.

Hi guys. I have to edit a csv file, the problem is that my special chars like ó ã ç gets screwed up. Heres is a peice of my code: static void ReadFromFile(){ StreamReader SR = new StreamReader("c:\\Users\\Levy\\Documents\\Vale\\Base\\Desknote.csv", Encoding.Default); StreamWriter SW = new StreamWriter("c:\\Users\\Levy...

WINDOWS/system32/LogFiles in use. How can I discover what program is using it? If it's the server, how can I use it too?

opening a file in WINDOWS/system32/LogFiles with using (StreamReader r = new StreamReader(fileName)) generates exception "because the file is in use by another process". How can I figure out what the other process is? Could it be the server updating the logs? If it is, how can I ensure that my associated scheduled task can also ha...

Reading from a HttpResponseStream fails

I'm running into an issue where reading from a HttpResponseStream fails because the StreamReader that I'm wrapping around in reads faster that the Response Stream gets the actual response. I'm retrieving a reasonably small sized file (around 60k) but the Parser which processes the response into an actual object fails because it hits an ...

C# can read from a file that doesn't exist?

Hi, We have some C# code that reads data from a text file using a StreamReader. On one computer we can read data from the text file even after it has been deleted or replaced with a different text file - the File.Exists call reports that the file exists even when it doesn't in Windows Explorer. However, on another computer this behaviou...

Long time to load first connection in C# .NET

I'm making a program that connects to a website and downloads XML from it. It then displays the information to the user. The problem I am having is when I first open the program and start downloading the XML information it takes a really long time. When I load another page from the site with the program still open, it takes about half ...

c# - StreamReader.ReadLine does not work properly!

Simply I have been trying to implement what BufferedStreamReader does in Java. I have a socket stream open and just want to read it in a line oriented fashion -line by line. I have following server-code while (continueProcess) { try { StreamReader reader = new StreamReader(Socket.GetStrea...

C# Why i get a NotSupported Exception on my file Path

StreamReader fr = new StreamReader("D:\\test\\" + item); This is what i want to do. Item is a String with the filename. The hole string is like that "D:\\test\\01-Marriotts Island.mp3" befor he tries to generate the StreamReader. whats wrong with the path? ...

How do I load text files into database that are greater than the 64 kb buffersize limit?

I'm trying to load text files (.aspx, .cs, html, etc) into a sql server 2008 database. I'm able to load all files that are less than 64 kb so far. I have two questions; How do I get around the 64 kb limit, and is the method I'm using the best way to do this? Thanks for the help. Database: file_length int, file_path varchar(250...

Memory efficiency :Passing Html code of aspx page through codebehind

My goal is to generate the aspx code of a page in the form of string.I am calling the below codebehind code through asynchronous request in javascript and i am getting the response back through Response.Write string html = string.Empty; using (var memoryStream = new MemoryStream()) { using (var stream...

Java-Sockets: InputStream.read() vs BufferedReader.read()

Hello I'm reading from a Socket's InputStream. Because I'm parsing the incoming data on the fly, I'm required to read character by character. Does BufferedReader.read() the same thing as InputStream.read() does ? (assuming that BufferedReader has been constructed with the InputStream as base) Is it more efficient to use InputStream.re...

NamedPipeClientStream StreamReader problem in C++

When reading from a NamedPipes server using the .net NamedPipeClientStream class I can only get the data on the first read in C++, every time it's just an empty string. In c# it works every time. pipeClient = gcnew NamedPipeClientStream(".", "Server_OUT", PipeDirection::In); try { pipeClient->Connect(); } catch(TimeoutException^ e)...

Avoiding 'End Of File' errors

I'm trying to import a tab delimited file into a table. The issue is, SOMETIMES, the file will include an awkward record that has two "null values" and causes my program to throw a "unexpected end of file". For example, each record will have 20 fields. But the last record will have only two fields (two null values), and hence, unexpec...

streamreader not reading from textfilewithin the project

I am using the streamreader to read from a file in the project.. StreamReader stRead = new StreamReader("textfile.txt"); while (!stRead.EndOfStream) { CheckBoxList1.Items.Add(stRead.ReadLine()); } but i get an error: Could not find file 'c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE...

StreamReader C#

While reading a text file(which contains the location of a file to be exported to a database) using the streamReader function in C#, how can I add a confirmation message to the code that will be displayed in the command prompt window(console application) so that I know the file got read and was exported? public class Script { public...

StreamReader, C#, peek

Hello, I have a StreamReader that once in a while check if it has more to read from a simple text file. It uses peek property. The problem is that when I am using peek the position is changed, althougth not suppose to. FileStream m_fsReader = new FileStream( m_strDataFileName, FileMode.Op...