How I parse tnsnames.ora file using Visual C# (Visual Studio 2008 Express edition) to get the tnsnames ? For instance, my tnsnames.ora file contains
ORCL =
public List ReadTextFile(string FP)
{
string inputString;
List List = new List();
try
{
StreamReader streamReader = File.OpenText(FP.Trim()); // FP is the filepath of TNS file
inputString = streamReader.ReadToEnd();
string[] temp = inputString.Split(new string[] {Environment.NewLine},StringSplitOptions.None);
for (int i = 0; i < temp.Length ;i++ )
{
if (temp[i].Trim(' ', '(').Contains("DESCRIPTION"))
{
string DS = temp[i-1].Trim('=', ' ');
List.Add(DS);
}
}
streamReader.Close();
}
catch (Exception EX)
{
}
return List;
}