473,320 Members | 1,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to get Application Path?

How to get Application Path?

I can't really use
System.Reflection.Assembly.GetExecutingAssembly(). GetName().CodeBase

because it returns the path in the file://c/winnt/.../filename.exe
format, which I can't really use to open files, etc...

I also don't want to use System.Windows.Forms.Application.ExecutablePath
because I don't want to include Windows Forms for my console app.

Thanks

Nov 13 '05 #1
5 147422
Hi,

Use Application.StartupPath

Nirosh.

"Frank Rizzo" <no****@nospam.com> wrote in message
news:eJ**************@tk2msftngp13.phx.gbl...
How to get Application Path?

I can't really use
System.Reflection.Assembly.GetExecutingAssembly(). GetName().CodeBase

because it returns the path in the file://c/winnt/.../filename.exe
format, which I can't really use to open files, etc...

I also don't want to use System.Windows.Forms.Application.ExecutablePath
because I don't want to include Windows Forms for my console app.

Thanks

Nov 13 '05 #2
Try Win32 API function GetCommandLine(). It should return the command line
with full application path. Sorry if it is not true, I don't have personal
experience with that.

Eliyahu

"Frank Rizzo" <no****@nospam.com> wrote in message
news:eJ**************@tk2msftngp13.phx.gbl...
How to get Application Path?

I can't really use
System.Reflection.Assembly.GetExecutingAssembly(). GetName().CodeBase

because it returns the path in the file://c/winnt/.../filename.exe
format, which I can't really use to open files, etc...

I also don't want to use System.Windows.Forms.Application.ExecutablePath
because I don't want to include Windows Forms for my console app.

Thanks

Nov 13 '05 #3
Have you tried System.Reflection.Assembly.GetExecutingAssembly(). Location

/Mikael

"Frank Rizzo" <no****@nospam.com> skrev i meddelandet
news:eJ**************@tk2msftngp13.phx.gbl...
How to get Application Path?

I can't really use
System.Reflection.Assembly.GetExecutingAssembly(). GetName().CodeBase

because it returns the path in the file://c/winnt/.../filename.exe
format, which I can't really use to open files, etc...

I also don't want to use System.Windows.Forms.Application.ExecutablePath
because I don't want to include Windows Forms for my console app.

Thanks

Nov 13 '05 #4
> Environment.CurrentDirectory

??

run cmd.exe
cd c:\
run prog for example
c:\winnt\prog.exe
if try write Environment.CurrentDirectory

it return "c:\"


--
Selvin - Przemek Sulikowski
se****@osadkowski.com.pl
Nov 13 '05 #5
Sorry I got busy with my office work so I didn't saw this

................., (You yourself fill the blank with the suitable word)

Yes I read to the end of the post and I understood it and bellow is how I ask you to do, though your small brain cannot get it.

Application.StarupPath doesn't use Windows Forms nore it return the path as file://c/winnt/.../filename.exe where you cannot use for file loading etc..
It will return the path in a way, which you can create a FileInfo object and use to get almost all the details you need such as directory, directoryName, File Name, Full Path etc,,,,,,,,,,,,,,,,

Other than that it will give the actual path even if you load the assembly using a Shoutcut icon.

Nirosh.
"Frank Rizzo" <no****@nospam.com> wrote in message news:u6**************@TK2MSFTNGP10.phx.gbl...
Dude,

Did you read the post to the end?

Champika Nirosh wrote:
Hi,

Use Application.StartupPath

Nirosh.

"Frank Rizzo" <no****@nospam.com> wrote in message
news:eJ**************@tk2msftngp13.phx.gbl...
How to get Application Path?

I can't really use
System.Reflection.Assembly.GetExecutingAssembly( ).GetName().CodeBase

because it returns the path in the file://c/winnt/.../filename.exe
format, which I can't really use to open files, etc...

I also don't want to use System.Windows.Forms.Application.ExecutablePath
because I don't want to include Windows Forms for my console app.



Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Timothy Shih | last post by:
Hi, I am having a freezing issue with my application. My application serves several remotable objects, all of which must be initialized before their use. Furthermore, some of them depend on each...
3
by: ramonred | last post by:
Hi, I have two web apps. Lets say main and admin for the sake of simplicity. admin is a web app within main (as a subdomain). So the path for admin is http://admin.main.com within the admin...
2
by: mark | last post by:
Can't figure this one out. I appears to not be code related. After surfing my asp.net web app for a while 5 - 10 min. it fails to open any further connections to my access 2000 database. There...
1
by: Keith | last post by:
All, I have been told this is an ASP.NET issue and not an IIS issue, so I am posting this here. I have a problem with ASP.NET returning an HTTP 500 error when trying to run ASPX pages on...
2
by: Ross | last post by:
Hi I have an application using asp.net that I am running on my PC. The web form has a text box where you can enter a name for a new Photo category then click on the button. The code is...
4
by: JOHN MALONEY | last post by:
Hi Everybody, I have created a three-tiered db application in VB .NET but I can't get the deployment to work right. I have added a SetUp project to the existing application. I also selected...
6
by: Ben Finney | last post by:
Howdy all, I'm improving an existing application that's partly written using Python and the standard library. Many of the improvements I want to make can be done by using third-party free...
0
by: steve | last post by:
I am using vb.net 2005 Express Edition. Application Settings would be a very useful thing, as a global program database that persists; if only it would work! Does anyone know a hack or a...
4
by: =?Utf-8?B?VkIgSm9ubmll?= | last post by:
I am at my witless end here, please help! I have an ASP.Net aspx web page, hosted on Windows Server 2003, that receives a query string with the path to an autocad drawing file selected from a...
0
by: Steve | last post by:
Hello- Your assistance with this issue is greatly appreciated. Environment: - Load-balanced IIS 6.0 servers (Win2003) - web servers point (via UNC path) to a Microsoft File Cluster on...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.