views:

29

answers:

1

I am processing some CSV file which i have copied in Bin folder of My ASP.NET Website.

When i execute

using (IDataReader csv = new CsvReader
               (new StreamReader("sample.txt"), true, '|'))
{
 .....
}

it complains me that "sample.txt" not found in "c:\Program Files\.....\"

Won't the runtime automatically look into the bin folder? what modification do i need to do?

+3  A: 

You need to specify a full path by calling Server.MapPath:

new StreamReader(Server.MapPath(@"~/bin/sample.txt"))

However, you should not put anything in the bin folder other than assemblies.
You should use the App_Data folder instead.

SLaks
What do you mean?
SLaks