I have the following code to read a file in the root directory of my application. For some reason, no matter how many runs, my file is still not being read. Any idea what I could be doing wrong here please. Thanks in advance.
byte[] mybytes = null;
if (File.Exists(filename))
{
using (StreamReader sr = new StreamReader(new FileStream(filename,
FileMode.Open, FileAccess.Read, FileShare.Read)))
{
String input;
StringBuilder tempstore = new StringBuilder();
while ((input = sr.ReadLine()) != null)
{
tempstore.Append(input);
}
mybytes = Encoding.ASCII.GetBytes(tempstore.ToString());
sr.Close();
}
}