Carptea del Assembly

14/10/2004 - 10:29 por Lars | Informe spam
Hola a todos,

¿Cómo puedo saber la carpeta en la que reside el ejecutable? Está, puede no
coincidir con el CurrentDirectory. Actualmente utilizo esto:

string dir = GetType().Assembly.CodeBase;
string toRemove = @"file://";
if (dir.StartsWith(toRemove))
{
dir = dir.Substring(toRemove.Length + 1);
}
dir = dir.Substring(0,dir.LastIndexOf("/"));

¿Alguna otra idea?

Muchas gracias.

Preguntas similare

Leer las respuestas

#1 Octavio Hernandez
14/10/2004 - 20:37 | Informe spam
Lars,

Mira la respuesta en esta página:

http://www.thescarms.com/dotNet/apppath.asp

Slds,

Octavio

"Lars" escribió en el mensaje
news:
Hola a todos,

¿Cómo puedo saber la carpeta en la que reside el ejecutable? Está, puede


no
coincidir con el CurrentDirectory. Actualmente utilizo esto:

string dir = GetType().Assembly.CodeBase;
string toRemove = @"file://";
if (dir.StartsWith(toRemove))
{
dir = dir.Substring(toRemove.Length + 1);
}
dir = dir.Substring(0,dir.LastIndexOf("/"));

¿Alguna otra idea?

Muchas gracias.


Respuesta Responder a este mensaje
#2 Guillermo guille
15/10/2004 - 04:05 | Informe spam
aquí tienes varias formas de ahcerlo (para VB y C#):
http://www.elguille.info/NET/dotnet/appPath2.htm

y aquí tienes otra forma más:
http://www.elguille.info/NET/dotnet/apppath.htm#cs

Nos vemos.
Guillermo
Microsoft VB MVP desde 1997
Te invito a mi sitio dedicado al VB y más...
http://www.elguille.info/
http://www.mundoprogramacion.com/
(puede que el correo usado sea anti-spam)


"Lars" wrote in message
news:
Hola a todos,

¿Cómo puedo saber la carpeta en la que reside el ejecutable? Está, puede no
coincidir con el CurrentDirectory. Actualmente utilizo esto:

string dir = GetType().Assembly.CodeBase;
string toRemove = @"file://";
if (dir.StartsWith(toRemove))
{
dir = dir.Substring(toRemove.Length + 1);
}
dir = dir.Substring(0,dir.LastIndexOf("/"));

¿Alguna otra idea?

Muchas gracias.


email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida