jtran007
asked on
streamreader error
Hi expert,
I have a text file whose content I check is ok; but I could not read this file. Also
I check nobody uses this file in my Pc.
Coud you give me a hand?
Thx,
JT
I have a text file whose content I check is ok; but I could not read this file. Also
I check nobody uses this file in my Pc.
Coud you give me a hand?
Thx,
JT
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace streamreader
{
class Program
{
static void Main(string[] args)
{
try
{
FileStream fs = new FileStream(@"c:\ratetable\Carriername.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite);
//FileStream fs = new FileStream("c:\\ratetable\\carrierinfo.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite);
using (StreamReader sr = new StreamReader(fs))
{
string strLine = null;
while ((strLine = sr.ReadLine()) != null)
{
Console.WriteLine(strLine);
}
sr.Close();
return;
}
}
catch (IOException err)
{
Console.WriteLine("An IO exception has been thrown!");
Console.WriteLine(err.ToString());
return;
}
}
}
}
carriername.txt.txt
what error on what line?
note:
the attached file is named Carriername.txt.txt
in the code, you try to open Carriername.txt
maybe ....
the attached file is named Carriername.txt.txt
in the code, you try to open Carriername.txt
maybe ....
ASKER
Hi expert,
1- I always get null return but no error
2- I check my file name is carriername.txt
Thx,
JT
1- I always get null return but no error
2- I check my file name is carriername.txt
Thx,
JT
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You are right.
ASKER
Thanks.
JT
JT