Connecting Tech Pros Worldwide Forums | Help | Site Map

Reading a text file with StreamReader

=?Utf-8?B?a20=?=
Guest
 
Posts: n/a
#1: Oct 15 '08
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.

sloan
Guest
 
Posts: n/a
#2: Oct 15 '08

re: Reading a text file with StreamReader


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:0102F58D-C3A9-45BD-A738-14E2B8BC3BA6@microsoft.com...
Quote:
>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.

sloan
Guest
 
Posts: n/a
#3: Oct 15 '08

re: Reading a text file with StreamReader


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" <sloan@ipass.netwrote in message
news:eefhPExLJHA.4772@TK2MSFTNGP03.phx.gbl...
Quote:
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:0102F58D-C3A9-45BD-A738-14E2B8BC3BA6@microsoft.com...
Quote:
>>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.
>
>

Closed Thread