Getting location of file tnsnames.ora by code

后端 未结 5 2052
野的像风
野的像风 2021-02-06 08:08

How can I get the location of the tnsnames.ora file by code, in a machine with the Oracle client installed?

Is there a windows registry key indicating the l

5条回答
  •  感动是毒
    2021-02-06 08:40

    List logicalDrives = Directory.GetLogicalDrives().ToList();
                List result = new List();
                foreach (string drive in logicalDrives)
                {
                    Console.WriteLine("Searching " + drive);
                    DriveInfo di = new DriveInfo(drive);
                    if(di.IsReady)
                        result = Directory.GetFiles(drive, "tnsnames.ora", SearchOption.AllDirectories).ToList();
                    if (0 < result.Count) return;
                }
                foreach (string file in result) { Console.WriteLine(result); }
    

提交回复
热议问题