<pre lang="cs">public string GetImagePath(string id)
{
const string f2 = "C:\\idimg.txt";
string myline;
using (StreamReader r = new StreamReader(f2))
{
while ((myline = r.ReadLine()) != null)
{
string[] attr = myline.Split('|');
string myidimage = attr[0].ToString().Trim();
string pathimage = attr[1];
if (id == myidimage)
{
myline = pathimage;
return myline;
}
return null;
}
}
Trim() spaces whenever you read a string from textfile...