Ver Mensaje Individual
  #7 (permalink)  
Antiguo 12/06/2006, 02:00
kakarot
 
Fecha de Ingreso: diciembre-2003
Mensajes: 288
Antigüedad: 21 años, 3 meses
Puntos: 0
Bueno uno que es cabezon, pero al final lo he conseguido, me ha quedado:

using System;
using System.IO;
using System.Collections;

namespace Conectar
{
/// <summary>
/// Descripción breve de Conexion.
/// </summary>
public class Conexion
{
private static string conexion;

public Conexion()
{
}//constructor

public string obtenerConexion()
{
string path=Directory.GetCurrentDirectory();
string slinea=cadenaConexion(path);
slinea=slinea+"ruta.txt";
StreamReader archivo=new StreamReader(slinea);
slinea="";
ArrayList aObj=new ArrayList();
while (slinea != null)
{
slinea = archivo.ReadLine();
if(slinea != null)
aObj.Add(slinea);
}
archivo.Close();
slinea=aObj[0].ToString();
return(slinea);
}//obtenerConexion

private string cadenaConexion(string cadena)
{
string path="";
int i=0;

while(cadena.Substring(i,3)!="bin")
{
path=path+cadena.Substring(i,1);
i++;
}//while
return(path);

}//cadenaConexion

public string PrConexion
{
get
{
return conexion;
}
set
{
conexion = value;
}
}

}//class
}

Ya se que será una barbaridad pero de momento funciona :D