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

.NET Framework 2.0 features on VS 2005.

I am tyring to use the .NET Framework 2.0 with Visual Studio 2005, but
I cannot get the System.IO / class method File ReadAllText feature to
work. How can I get this to work with VS 2005?

Thanks,
Paul

Jan 28 '07 #1
7 1326
Hello Paul,

What the problem is?
Have u tried MSDN sample http://msdn2.microsoft.com/en-us/library/ms143368.aspx
?

PLI am tyring to use the .NET Framework 2.0 with Visual Studio 2005,
PLbut I cannot get the System.IO / class method File ReadAllText
PLfeature to work. How can I get this to work with VS 2005?
PL>
PLThanks,
PLPaul
---
WBR, Michael Nemtsev [C# MVP] blog: http://spaces.live.com/laflour
team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
Jan 28 '07 #2
In VB2005:

'Read in a file and split the lines by CrLf
Dim crlfs() as String = {ControlChars.CrLf}
Dim lines() as String = _
File.ReadAllText("c:\data.txt").Split(crlfs, StringSplitOptions.None)
Dim numOfLines = lines.Length

If you want more help, you will need to tell exactly what's
not working, and post your code.

Robin S.
-----------------------------------------------
"Paul Lemelle" <Pl******@comcast.netwrote in message
news:6u********************************@4ax.com...
>I am tyring to use the .NET Framework 2.0 with Visual Studio 2005, but
I cannot get the System.IO / class method File ReadAllText feature to
work. How can I get this to work with VS 2005?

Thanks,
Paul

Jan 29 '07 #3
I am using C#, and here is the code:

using system;
using system.IO;

namespace FileIO

Class File
{
public static void Main ()
{
string myfile = File.ReadAllText("myfile");
// I do not get the File.ReadAllText - I only get Equals, Main,
// & ReferenceEquals after File.
Console.Writeline(myfile);
}
}

The code fills because the compiler does not know what to do with the
File.ReadAllText method.

Paul


On Sun, 28 Jan 2007 17:02:31 -0800, "RobinS" <Ro****@NoSpam.yah.none>
wrote:
>In VB2005:

'Read in a file and split the lines by CrLf
Dim crlfs() as String = {ControlChars.CrLf}
Dim lines() as String = _
File.ReadAllText("c:\data.txt").Split(crlfs, StringSplitOptions.None)
Dim numOfLines = lines.Length

If you want more help, you will need to tell exactly what's
not working, and post your code.

Robin S.
-----------------------------------------------
"Paul Lemelle" <Pl******@comcast.netwrote in message
news:6u********************************@4ax.com.. .
>>I am tyring to use the .NET Framework 2.0 with Visual Studio 2005, but
I cannot get the System.IO / class method File ReadAllText feature to
work. How can I get this to work with VS 2005?

Thanks,
Paul
Jan 29 '07 #4
I tried this, and it worked fine. I think your problem is your file name
"myfile". My guess is that it can not find the file. Try a file with a
path, like "C:\Test.txt".

Also be sure you have "using System.IO;" at the top of your class.

And Writeline should be WriteLine. C# is case-sensitive.

Robin S.
-------------------------------------
"Paul Lemelle" <Pl******@comcast.netwrote in message
news:0h********************************@4ax.com...
>I am using C#, and here is the code:

using system;
using system.IO;

namespace FileIO

Class File
{
public static void Main ()
{
string myfile = File.ReadAllText("myfile");
// I do not get the File.ReadAllText - I only get Equals, Main,
// & ReferenceEquals after File.
Console.Writeline(myfile);
}
}

The code fills because the compiler does not know what to do with the
File.ReadAllText method.

Paul


On Sun, 28 Jan 2007 17:02:31 -0800, "RobinS" <Ro****@NoSpam.yah.none>
wrote:
>>In VB2005:

'Read in a file and split the lines by CrLf
Dim crlfs() as String = {ControlChars.CrLf}
Dim lines() as String = _
File.ReadAllText("c:\data.txt").Split(crlfs, StringSplitOptions.None)
Dim numOfLines = lines.Length

If you want more help, you will need to tell exactly what's
not working, and post your code.

Robin S.
-----------------------------------------------
"Paul Lemelle" <Pl******@comcast.netwrote in message
news:6u********************************@4ax.com. ..
>>>I am tyring to use the .NET Framework 2.0 with Visual Studio 2005, but
I cannot get the System.IO / class method File ReadAllText feature to
work. How can I get this to work with VS 2005?

Thanks,
Paul

Jan 29 '07 #5
Naming you class as "File" is a bad choice.

You code will not compile, since you also used "System.IO" name space, which
has a class called "File". You need to qualify the class "File" to
distinguish which namespace it belongs to:

string myfile=System.IO.File.ReadAllText(...) //If the ReadAllText is not
from your custom class

or

string myfile=FileIO.File.ReadAllText(...) //If your "File" class
defines the method with the same name.

I strongly recommend you name your namespace/class wisely.
"Paul Lemelle" <Pl******@comcast.netwrote in message
news:0h********************************@4ax.com...
>I am using C#, and here is the code:

using system;
using system.IO;

namespace FileIO

Class File
{
public static void Main ()
{
string myfile = File.ReadAllText("myfile");
// I do not get the File.ReadAllText - I only get Equals, Main,
// & ReferenceEquals after File.
Console.Writeline(myfile);
}
}

The code fills because the compiler does not know what to do with the
File.ReadAllText method.

Paul


On Sun, 28 Jan 2007 17:02:31 -0800, "RobinS" <Ro****@NoSpam.yah.none>
wrote:
>>In VB2005:

'Read in a file and split the lines by CrLf
Dim crlfs() as String = {ControlChars.CrLf}
Dim lines() as String = _
File.ReadAllText("c:\data.txt").Split(crlfs, StringSplitOptions.None)
Dim numOfLines = lines.Length

If you want more help, you will need to tell exactly what's
not working, and post your code.

Robin S.
-----------------------------------------------
"Paul Lemelle" <Pl******@comcast.netwrote in message
news:6u********************************@4ax.com. ..
>>>I am tyring to use the .NET Framework 2.0 with Visual Studio 2005, but
I cannot get the System.IO / class method File ReadAllText feature to
work. How can I get this to work with VS 2005?

Thanks,
Paul

Jan 29 '07 #6
hi Norman,

That was it - thanks.

Paul
On Mon, 29 Jan 2007 07:33:27 -0700, "Norman Yuan"
<No*****@NotReal.notwrote:
>Naming you class as "File" is a bad choice.

You code will not compile, since you also used "System.IO" name space, which
has a class called "File". You need to qualify the class "File" to
distinguish which namespace it belongs to:

string myfile=System.IO.File.ReadAllText(...) //If the ReadAllText is not
from your custom class

or

string myfile=FileIO.File.ReadAllText(...) //If your "File" class
defines the method with the same name.

I strongly recommend you name your namespace/class wisely.
"Paul Lemelle" <Pl******@comcast.netwrote in message
news:0h********************************@4ax.com.. .
>>I am using C#, and here is the code:

using system;
using system.IO;

namespace FileIO

Class File
{
public static void Main ()
{
string myfile = File.ReadAllText("myfile");
// I do not get the File.ReadAllText - I only get Equals, Main,
// & ReferenceEquals after File.
Console.Writeline(myfile);
}
}

The code fills because the compiler does not know what to do with the
File.ReadAllText method.

Paul


On Sun, 28 Jan 2007 17:02:31 -0800, "RobinS" <Ro****@NoSpam.yah.none>
wrote:
>>>In VB2005:

'Read in a file and split the lines by CrLf
Dim crlfs() as String = {ControlChars.CrLf}
Dim lines() as String = _
File.ReadAllText("c:\data.txt").Split(crlfs, StringSplitOptions.None)
Dim numOfLines = lines.Length

If you want more help, you will need to tell exactly what's
not working, and post your code.

Robin S.
-----------------------------------------------
"Paul Lemelle" <Pl******@comcast.netwrote in message
news:6u********************************@4ax.com ...
I am tyring to use the .NET Framework 2.0 with Visual Studio 2005, but
I cannot get the System.IO / class method File ReadAllText feature to
work. How can I get this to work with VS 2005?

Thanks,
Paul

Jan 29 '07 #7
Paul Lemelle <Pl******@comcast.netwrote:
I am using C#, and here is the code:

using system;
using system.IO;

namespace FileIO

Class File
{
public static void Main ()
{
string myfile = File.ReadAllText("myfile");
// I do not get the File.ReadAllText - I only get Equals, Main,
// & ReferenceEquals after File.
Console.Writeline(myfile);
}
}
That's certainly not the code you had mostly working - it's really
helpful if you cut and paste the *actual* code in, rather than creating
a *similar* program which will fail for other reasons. Problems with
the above, *apart* from the collision of the "File" name:

1) Case of "system"
2) No braces after the namespace declaration
3) Case of class declaration
4) Case of the "l" in Writeline

In general, if you've already got a problem in your code, it makes it
hard for us to tell the problems which are *really* there compared with
typos when retyping the code unless you use cut and paste properly.

--
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
Jan 29 '07 #8

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

Similar topics

11
by: Geoff Cox | last post by:
Hello, The .NET Framework is about 20MB which is large compared to some apps. Can I assume that the Framework is on modern PCs? Does modern mean PCs sold in the last 6 months, 12 months, etc?? ...
3
by: Michel | last post by:
Hola, saludos a todos, tengo una duda, yo isntale un Update de Microsoft ( Microsoft .NET Framework 2.0: x86 (KB829019)), tambien baje e instale la ..NET Framework SDK 2.0, y estaba leyendo en...
5
by: Tom Costanza | last post by:
Is it possible to have VS2005 compile code for the version 1.1 Framework? All my users have the 1.1 framework and I'd like to not install the 2.0 framework. Thanks, Tom Costanza
0
by: innovasys | last post by:
TORQUAY, DEVON, UK - Innovasys announced the release of Document! X 5, the fifth version of the documentation solution of choice for developers using Microsoft Visual Studio or the .NET Framework....
12
by: jtertin | last post by:
Can you force VS 2005 to compile a program to be compatible with version 1.x of the .NET Framework? HOW!?
2
by: Zer0 | last post by:
Hi people, I'm basically wondering if it is possisble to create an application for the PocketPC using the Compact Framework and use it on both the desktop PC and the PocketPC. As this will same me...
0
by: fionab | last post by:
Reading, Berkshire, UK - Crainiate Software announce the release of Objecto Framework 1.0, a new component framework 5 years in development, designed to make it easy for programmers to create agile...
7
by: Shawn B. | last post by:
Greetings, I have a question. The framework SDK ships with a CS/VB.NET compiler. Does the Visual Studio 2005 IDE use these compilers or does the IDE have its own? This has me thinking. ...
6
by: amparikh | last post by:
I have VS.NET 2003 IDE and compiler. Are there any knwon issues using .NET 3.0 SDK with VS.NET 2003 ? or just including the right header files and libraries within the SDK should do it ? Thanks
11
by: active | last post by:
If I install .NET Framework 3.0 what will happen to my VS2005 experience? Will it automatically use 3.0? Will I find new features available? Will the VS doc be updated? Thanks fir any...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.