What means it doesn't work? If you got the NullReference exception it means
you are working with empty file (readline returns true when there is nothing
more to read).
About the sleep... you must use System.Threading.Thread.Sleep for this
purpose :)
2009/7/24 Le Tubs <[email protected]>

>
> Hi
>
> I have been playing around with Visual c# and I'm trying to work out
> whether its me or c# (I'm from a c background btw). Have created a
> simple little program to read the contents of a file in ....
> Now I have found something rather strange (the files do exist in
> these
> locations) if I use this line in the code stub below ...
>
>
>   FileStream filePTR = new FileStream("C:\\findme.txt",
> FileMode.Open, FileAccess.Read);
>
>
> It works...
>
>
> Yet If I use this line
>
>
>    FileStream filePTR = new FileStream("C:\\Dr1\\Dr2\\findme.txt",
> FileMode.Open, FileAccess.Read);
>
>
> it doesn't. So am I wondering is it me or am I missing something
> fundermental?. Thanks in advance for time and consideration, btw does
> c# have a sleep command?or do you just use the
> for( int i = 1; i ,= 1000000 ; i++ ){}.
>
>
> Thanks in advance for your time on this question.
>
>
> Le Tubs
>
>
> string line;
>            //Pass the file path and file name to the FileStream
> constructor
>           ** FileStream filePTR = new FileStream("C:\\Dr1\
> \findme.txt", FileMode.Open, FileAccess.Read);
>            StreamReader sr = new StreamReader(filePTR);
>            //Read the first line of text
>            line = sr.ReadLine();
>            Console.WriteLine(" ... {0} ", line);
>            sr.Close();
>
>
>

Reply via email to