Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void readData()
- {
- TextReader readFile;
- string chain;
- bool found = false;
- string[] fields = new string[2];
- char[] breakUp = { ':' };
- try
- {
- readFile = new StreamReader("C:\Users\unam\Documents\Hugo\Datos.txt");
- chain = readFile.ReadLine();
- while (chain != null && found == false)
- {
- fields = chain.Split(breakUp);
- if (fields[0].Trim().Equals("Postgre_Server"))
- {
- server = fields[1].Trim();
- }else
- {
- if(fields[0].Trim().Equals("Postgre_Port"))
- {
- port = fields[1].Trim();
- }else
- {
- if(fields[0].Trim().Equals("Postgre_Password"))
- {
- password = fieldas[1].Trim();
- }
- }
- }
- } //End While
- readFile.Close();
- }catch(FileNotFoundException fe)
- {
- Console.WriteLine("¡No se encontró el archivo!" + fe.Message);
- }catch(Exception e)
- {
- Console.WriteLine("¡No se encontró el archivo!" + e.Message);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement