PC Review


Reply
Thread Tools Rate Thread

.NET Framework 2.0 features on VS 2005.

 
 
Paul Lemelle
Guest
Posts: n/a
 
      28th Jan 2007
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

 
Reply With Quote
 
 
 
 
Michael Nemtsev
Guest
Posts: n/a
 
      28th Jan 2007
Hello Paul,

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

PL> I am tyring to use the .NET Framework 2.0 with Visual Studio 2005,
PL> but I cannot get the System.IO / class method File ReadAllText
PL> feature to work. How can I get this to work with VS 2005?
PL>
PL> Thanks,
PL> Paul
---
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


 
Reply With Quote
 
 
 
 
RobinS
Guest
Posts: n/a
 
      29th Jan 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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
>



 
Reply With Quote
 
Paul Lemelle
Guest
Posts: n/a
 
      29th Jan 2007
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" <(E-Mail Removed)>
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" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>>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
>>

>


 
Reply With Quote
 
RobinS
Guest
Posts: n/a
 
      29th Jan 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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" <(E-Mail Removed)>
> 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" <(E-Mail Removed)> wrote in message
>>news:(E-Mail Removed)...
>>>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
>>>

>>

>



 
Reply With Quote
 
Norman Yuan
Guest
Posts: n/a
 
      29th Jan 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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" <(E-Mail Removed)>
> 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" <(E-Mail Removed)> wrote in message
>>news:(E-Mail Removed)...
>>>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
>>>

>>

>



 
Reply With Quote
 
Paul Lemelle
Guest
Posts: n/a
 
      29th Jan 2007
hi Norman,

That was it - thanks.

Paul


On Mon, 29 Jan 2007 07:33:27 -0700, "Norman Yuan"
<(E-Mail Removed)> wrote:

>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" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>>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" <(E-Mail Removed)>
>> 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" <(E-Mail Removed)> wrote in message
>>>news:(E-Mail Removed)...
>>>>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
>>>>
>>>

>>

>


 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      29th Jan 2007
Paul Lemelle <(E-Mail Removed)> wrote:
> 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 - <(E-Mail Removed)>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Media Center features vs. Pro features =?Utf-8?B?dGpfNw==?= Windows XP Help 2 24th May 2006 03:20 AM
Some MS Office features should be OS features =?Utf-8?B?c2FlMTk2Mg==?= Windows XP General 0 29th Dec 2005 04:30 PM
Does Messenger 7 require Framework update to use all features? Lori A. Kuiper Windows XP Messenger 1 17th Apr 2005 10:03 PM
Re: Framework 2.0 features? Oren Novotny Microsoft Dot NET Framework 0 8th Aug 2003 07:21 PM
simple TCP socket connect (emulator - framework FAIL); framework - framework - Works [Help will be compensated] Yechezkal Gutfreund Microsoft Dot NET Compact Framework 0 16th Jul 2003 06:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:22 AM.