471,337 Members | 859 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

how to read txt file

Project/add/existing item/File type *.* --> temp.txt
how to read temp.txt
Dec 22 '05 #1
3 1420
Hi,

You mean in code?

StreamReader is your answer

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Riccio" <ri*****@snap.it> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Project/add/existing item/File type *.* --> temp.txt
how to read temp.txt

Dec 22 '05 #2
Hi,

If you add the file into your project this file is copied on the solution
folder and not on the "Bin" folder, therefore if you need to read it you need
to copy it on the BIN folder or add a PostBuild event to copy the file
(usually what I do).

Then to read the file you can use the FileStream
using (StreamReader ReadStream = System.IO.File.OpenText("yourFile.txt"))
{
string Content = ReadStream.ReadToEnd();
}

Cheers
--
Salvador Alvarez Patuel
Exony Ltd - London, UK
"Riccio" wrote:
Project/add/existing item/File type *.* --> temp.txt
how to read temp.txt

Dec 22 '05 #3
Riccio <ri*****@snap.it> wrote:
Project/add/existing item/File type *.* --> temp.txt
how to read temp.txt


Salvador's answer is fine for "content" resources, but I'd suggest
making the file an embedded resource unless it actually needs to be
changed after build. Then you can use
Assembly.GetManifestResourceStream to open a stream, and wrap a
StreamReader round it. It makes life easier if you only have to copy
the assembly around, rather than other files as well :)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Dec 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Yang Li Ke | last post: by
10 posts views Thread by ZafT | last post: by
4 posts views Thread by ESPN Lover | last post: by
8 posts views Thread by a | last post: by
5 posts views Thread by lovecreatesbea... | last post: by
6 posts views Thread by Thomas Kowalski | last post: by
9 posts views Thread by flebber | last post: by
2 posts views Thread by Kevin Ar18 | last post: by

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.