473,394 Members | 2,063 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,394 software developers and data experts.

C# App: application.startuppath

getgagan
how to find Main folder where bin folder exists using application.startuppath in c#

IF
application.startuppath=D:\Test\ThreadExample\DnsL ookup\DnsLookup\bin\Debug

Then i need to find the folder exactly like :
D:\Test\ThreadExample\DnsLookup\DnsLookup

how ??
Dec 14 '07 #1
5 20361
shweta123
692 Expert 512MB
Hi,

There is no function provided by .Net framework to get the application path
as mentioned by you. But you can do it this way :

e.g.
yourpath = "D:\Test\ThreadExample\DnsLookup\DnsLookup\bin\Deb ug"
path=yourpath.Substring(1, yourpath.IndexOf("\bin"))


how to find Main folder where bin folder exists using application.startuppath in c#

IF
application.startuppath=D:\Test\ThreadExample\DnsL ookup\DnsLookup\bin\Debug

Then i need to find the folder exactly like :
D:\Test\ThreadExample\DnsLookup\DnsLookup

how ??
Dec 14 '07 #2
demaus
6
This depends on which Framework you are using. If you are using VS2005 then you should have the ability to get the directory path with:

Expand|Select|Wrap|Line Numbers
  1.  
  2. My.Application.Info.DirectoryPath
  3.  
  4.  
Haven't tried this in C# though so maybe it won't work for you.
Dec 14 '07 #3
We can do Like this as in above reply


But I forget, I hv used something like this "\.." to find parent folder of application.startuppath. and "\.. \.." to get parent of parent(application.startuppath). but now this is not working as due to syntex error

Can anyone help ??
Dec 15 '07 #4
shweta123
692 Expert 512MB
Hi,

What code have you written and what is the error that you are getting?

We can do Like this as in above reply


But I forget, I hv used something like this "\.." to find parent folder of application.startuppath. and "\.. \.." to get parent of parent(application.startuppath). but now this is not working as due to syntex error

Can anyone help ??
Dec 16 '07 #5
Shashi Sadasivan
1,435 Expert 1GB
The full directory path where your exe file is run from will be determined by

AppDomain.CurrentDomain.BaseDirectory

(I have been using this)
cheers
Dec 16 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: VMI | last post by:
Is there an Application.StartupPath equivalent for web? I want to open a txt file myFile.txt and it will always be on the same dir the aspx will be, but I don't want to give it a fixed path. ...
8
by: jcrouse | last post by:
I am trying to run a command from a command prompt using the shell command. Here is the syntax I want to execute: Shell(lblMameExePath.Text & " -listinfo >" & Application.StartupPath &...
4
by: kd | last post by:
Hi All, Is there an equivalent for Application.StartupPath in a console application? kd
1
by: Sean | last post by:
Hi I created a VB.NET console app. I try to use the Application.StartupPath() but got an error: Name 'Application' is not declared. Any idea? Thanks. Sean
3
by: hayworth | last post by:
I had some code to build the name of a file: ' Build the name of the XML config file. g_strFiles.strConfig = My.Computer.FileSystem.CombinePath(Application.StartupPath, "\Settings\Config...
2
by: al jones | last post by:
There is no installation for the program I wrote, one just copies the files to some directory and runs it from there, I have both a working program and help file (.chm). From within the IDE...
3
by: kimiraikkonen | last post by:
Hello experts, I want my external application run from the root folder where my project (.exe) resides. For example, my main project (.exe) should be in the same directory with my external file...
0
by: =?Utf-8?B?U2hlbGRvbg==?= | last post by:
Hello - I am trying to access a Crystal Report. VS 2008 automatically creates the report in the same directory as the forms. When attempting to use Application.StartupPath, it takes me to the...
2
satiss7pwr
by: satiss7pwr | last post by:
i have one window application developed in VS 2005 which is running successfully on client side,My question is that now i want to convert this window application in WPF browser based application, so...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.