473,394 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Reading a text file with StreamReader

I have a tab delimited text file that I open in Excel.
While it is open in Excel I need to open and read it from my C# application.
I get an access error opening the file with StreamReader or File.Open
The error message says that another application has the file open (which of
course I already knew).

Notepad can open the file while it is open in Excel. Why can't the framework?

I've tried specifying the access as read-only, no luck.

Any suggestions would be appreciated.
Oct 15 '08 #1
2 2979
You can try the OleDb

http://blogs.msdn.com/gzunino/archiv...02/206377.aspx

I have a very basic excel and txt reader here:
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!176.entry
(downloadable code)

Or google
OleDbReader Excel
or
OleDbReader txt
"km" <km@discussions.microsoft.comwrote in message
news:01**********************************@microsof t.com...
>I have a tab delimited text file that I open in Excel.
While it is open in Excel I need to open and read it from my C#
application.
I get an access error opening the file with StreamReader or File.Open
The error message says that another application has the file open (which
of
course I already knew).

Notepad can open the file while it is open in Excel. Why can't the
framework?

I've tried specifying the access as read-only, no luck.

Any suggestions would be appreciated.

Oct 15 '08 #2
When I say "try", I mean, I have no idea if it'll work or not.

Excel is obviously putting a lock on the file.
Check the "Open As" options under Excel, if they exist.


"sloan" <sl***@ipass.netwrote in message
news:ee**************@TK2MSFTNGP03.phx.gbl...
You can try the OleDb

http://blogs.msdn.com/gzunino/archiv...02/206377.aspx

I have a very basic excel and txt reader here:
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!176.entry
(downloadable code)

Or google
OleDbReader Excel
or
OleDbReader txt
"km" <km@discussions.microsoft.comwrote in message
news:01**********************************@microsof t.com...
>>I have a tab delimited text file that I open in Excel.
While it is open in Excel I need to open and read it from my C#
application.
I get an access error opening the file with StreamReader or File.Open
The error message says that another application has the file open (which
of
course I already knew).

Notepad can open the file while it is open in Excel. Why can't the
framework?

I've tried specifying the access as read-only, no luck.

Any suggestions would be appreciated.


Oct 15 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: jamait | last post by:
Hi all, I m trying to read in a text file into a datatable... Not sure on how to split up the information though, regex or substrings...? sample: Col1 Col2 ...
1
by: mail2atulmehta | last post by:
Hi, I do not know if this is right place for this, but i need some help. I have a text file, whose values are seprated by a delimiter. I want to open this file in excel, ( not import it) . I have...
2
by: Sabin Finateanu | last post by:
Hi I'm having problem reading a file from my program and I think it's from a procedure I'm using but I don't see where I'm going wrong. Here is the code: public bool AllowUsage() { ...
13
by: mloichate | last post by:
I must read a very heavy-weight text plain file (usually .txt extension) )and replace a given character with another given character in all text inside the file. My application was working pretty...
9
by: haibhoang | last post by:
I have a Windows Service that is trying to parse a large (> 1Gig) text file. I am keep getting OutOfMemoryException exception. Here is the code that's having problem: using (StreamReader...
3
by: leticia larrosa | last post by:
Hi, I try to read a file that have 8 bit character, but contain some character whose code is more than 128 (spanish character). When I read this file using ASCII (Dim oRead As StreamReader =...
9
by: jeff M via .NET 247 | last post by:
I'm still having problems reading EBCDIC files. Currently itlooks like the lower range (0 to 127) is working. I have triedthe following code pages 20284, 20924, 1140, 37, 500 and 20127.By working I...
7
by: Drew Berkemeyer | last post by:
Hello, I'm using the following code to read a text file in VB.NET. Dim sr As StreamReader = File.OpenText(strFilePath) Dim input As String = sr.ReadLine() While Not input Is Nothing...
2
by: James Wong | last post by:
Dear all, I'm using StreamReader to read a text file containing BIG-5 data and found that no matter which encoding method in StreamReader's construction parameter, the BIG-5 contents become...
4
by: Amit Maheshwari | last post by:
I need to read text file having data either comma seperated or tab seperated or any custom seperator and convert into a DataSet in C# . I tried Microsoft Text Driver and Microsoft.Jet.OLEDB.4.0...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.