473,421 Members | 1,615 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,421 software developers and data experts.

load txt file into a string

How can I load a text file into a normal string?

I tried this:

System.IO.StreamReader file = new System.IO.StreamReader(@"\test.txt");
string test = file.ToString();

This does not work. The value of the string is "System.IO.StreamReader". How
can I do this?

Thanks for your help

Chris
Nov 16 '05 #1
2 27840
string test = file.ReadToEnd();

will do the job.

Bruno

"chris" <ch***@discussions.microsoft.com> a écrit dans le message de news:
76**********************************@microsoft.com...
How can I load a text file into a normal string?

I tried this:

System.IO.StreamReader file = new System.IO.StreamReader(@"\test.txt");
string test = file.ToString();

This does not work. The value of the string is "System.IO.StreamReader".
How
can I do this?

Thanks for your help

Chris

Nov 16 '05 #2
Chris,

The answer on your question is completly given on this page

http://msdn.microsoft.com/library/de...xtFromFile.asp

I hope this helps,

Cor
Nov 16 '05 #3

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

Similar topics

1
by: Uthuras | last post by:
Greetings, Machine : Pentium IV Os Windows 2000 server Product : DB2 UDB Release : 7.2 We are fail to load the following data file format into db2 database table that has long varchar...
2
by: Lauren Hines | last post by:
Hello, I have read numerous post stating that the only way to unload an assembly (DLL in my case) is to create a separate AppDomain, load the assembly, then unload it by calling AppDomain.Unload....
0
by: phillip | last post by:
This is interesting, I have attached my web.config file and the exception I have been logging. I created a library which provide data access to a database and a control system. The library is...
0
by: Simon | last post by:
Hi I try to open a CR report file located on the network path from a web form developed with vs2003 and CR for Visual Studio, but the Load method of ReportDocument object always return error. ...
6
by: Andy Sutorius via DotNetMonster.com | last post by:
Using the code below the browser just sits and spins. The dll is located in the root of the web app. System.Runtime.Interop is in the using statements. I have tried this in ASP.NET 1.1 and 2.0 and...
0
by: delphiconsultingguy | last post by:
Hi all, Spent WAAAYYY too much time trying to figure this out because there's not many good examples out there, so in the interest of sparing y'all from suff'rin same, I've pasted it into...
4
by: DanThMan | last post by:
The following code works when I debug and when I install the software and run the .exe, but if I try to open the form in the designer (which causes this code to run), I get an error: Private Sub...
1
by: pzero24 | last post by:
Ok so I am making plugins for my application and I have the plugins located in a subdirectory: /AppDir /AppDir/Plugins All my plugins reference a Plugins interface file, which is also located...
2
by: David Thielen | last post by:
So we have moved our app from .NET version 2.X in IIS6 to a Windows 2008 Server running IIS7. We have copied all files to the Windwardreports\apps directory and that apps directory has been...
4
by: lasida | last post by:
Hi, I have developed an application in C#. Now I'm working on a tool which is again written in c# which will give me all the assemblies referenced by my application. In the code i need to get...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.