473,789 Members | 2,806 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dumb question - How can I get the app.path from .NET?

what's the equivalent syntax for app.path in VB.NET?
Thanks
Bill
Nov 20 '05 #1
14 1392
CMG
I usually put the following up with the declarations...
Dim AppFolder As String =
System.Windows. Forms.Applicati on.ExecutablePa th.Substring
(0,
System.Windows. Forms.Applicati on.ExecutablePa th.LastIndexO
f("\") + 1)

AppFolder then points to the exact folder ur exe is
running from with the trailing \
-----Original Message-----
what's the equivalent syntax for app.path in VB.NET?
Thanks
Bill
.

Nov 20 '05 #2
With Deft Fingers, "Bill Nguyen" <bi************ *****@jaco.com> wrote:
what's the equivalent syntax for app.path in VB.NET?


Dim appPath As String ' Application Start Path

appPath = System.Windows. Forms.Applicati on.StartupPath

And I think you need:

Imports System.IO
Regards,

Bruce
Nov 20 '05 #3
You were doing really well up to the ExecutablePath property :-)
However, rather than manually parsing out the directory name, you might want
to consider using the System.IO.Path class instead.
There are occassions where your parsing can fail - for example, if the
application was run from a URL.

-Rob Teixeira [MVP]

"CMG" <vb****@divx-warez.nl> wrote in message
news:06******** *************** *****@phx.gbl.. .
I usually put the following up with the declarations...
Dim AppFolder As String =
System.Windows. Forms.Applicati on.ExecutablePa th.Substring
(0,
System.Windows. Forms.Applicati on.ExecutablePa th.LastIndexO
f("\") + 1)

AppFolder then points to the exact folder ur exe is
running from with the trailing \
-----Original Message-----
what's the equivalent syntax for app.path in VB.NET?
Thanks
Bill
.

Nov 20 '05 #4
CMG
Thanx for the info. Never ran a exe from an url befor,
prolly aint going to in the near future, so for now, this
is perfect for me. I was just trying to help the guy, i
am no where near an MVP or what so ever, i just started
vb.net a couple of months ago just for my own fun.
-----Original Message-----
You were doing really well up to the ExecutablePath property :-)However, rather than manually parsing out the directory name, you might wantto consider using the System.IO.Path class instead.
There are occassions where your parsing can fail - for example, if theapplication was run from a URL.

-Rob Teixeira [MVP]

"CMG" <vb****@divx-warez.nl> wrote in message
news:06******* *************** ******@phx.gbl. ..
I usually put the following up with the declarations...
Dim AppFolder As String =
System.Windows. Forms.Applicati on.ExecutablePa th.Substring (0,
System.Windows. Forms.Applicati on.ExecutablePa th.LastIndexO f("\") + 1)

AppFolder then points to the exact folder ur exe is
running from with the trailing \
>-----Original Message-----
>what's the equivalent syntax for app.path in VB.NET?
>Thanks
>Bill
>
>
>.
>

.

Nov 20 '05 #5
Perfect!
Thanks Mr. B, CMG, and Rob for your quick response!
Bill

"Mr. B" <Us**@NoWhere.c om> wrote in message
news:kg******** *************** *********@4ax.c om...
With Deft Fingers, "Bill Nguyen" <bi************ *****@jaco.com> wrote:
what's the equivalent syntax for app.path in VB.NET?


Dim appPath As String ' Application Start Path

appPath = System.Windows. Forms.Applicati on.StartupPath

And I think you need:

Imports System.IO
Regards,

Bruce

Nov 20 '05 #6
Oh, don't get me wrong, I'm not critisizing your response. Please continue
to contribute.
I was just adding info for everyone's benefit. We're all here to learn,
after all :-)

-Rob Teixeira [MVP]

"CMG" <vb****@divx-warez.nl> wrote in message
news:07******** *************** *****@phx.gbl.. .
Thanx for the info. Never ran a exe from an url befor,
prolly aint going to in the near future, so for now, this
is perfect for me. I was just trying to help the guy, i
am no where near an MVP or what so ever, i just started
vb.net a couple of months ago just for my own fun.

Nov 20 '05 #7
CMG
Hehe, sorry if my post seemed sarcastic, it was not ment
that way ;) i know you mean well, so do i, and in the
end, by trying to help some one i learned something
myself, so, i'm happy u responded also :)

Greetz,

CMG
-----Original Message-----
Oh, don't get me wrong, I'm not critisizing your response. Please continueto contribute.
I was just adding info for everyone's benefit. We're all here to learn,after all :-)

-Rob Teixeira [MVP]

"CMG" <vb****@divx-warez.nl> wrote in message
news:07******* *************** ******@phx.gbl. ..
Thanx for the info. Never ran a exe from an url befor,
prolly aint going to in the near future, so for now, this is perfect for me. I was just trying to help the guy, i
am no where near an MVP or what so ever, i just started
vb.net a couple of months ago just for my own fun.

.

Nov 20 '05 #8
CMG
NP, i was glad there are some questions that new ppl like
me can awnser :)
-----Original Message-----
Perfect!
Thanks Mr. B, CMG, and Rob for your quick response!
Bill

"Mr. B" <Us**@NoWhere.c om> wrote in message
news:kg******* *************** **********@4ax. com...
With Deft Fingers, "Bill Nguyen" <bi************ *****@jaco.com> wrote:
>what's the equivalent syntax for app.path in VB.NET?


Dim appPath As String ' Application Start Path
appPath = System.Windows. Forms.Applicati on.StartupPath
And I think you need:

Imports System.IO
Regards,

Bruce

.

Nov 20 '05 #9
* "Bill Nguyen" <bi************ *****@jaco.com> scripsit:
what's the equivalent syntax for app.path in VB.NET?


\\\
Imports System.IO
Imports System.Reflecti on
..
..
..
Private Function ApplicationPath () As String
Return _
Path.GetDirecto ryName([Assembly].GetExecutingAs sembly().Locati on)
End Function
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #10

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

Similar topics

16
2517
by: squash | last post by:
a dumb question i had on my mind: Say you have a dynamically created web page . Isn't it more secure to write it in php since a visitor will not be able to tell it is dynamically created? But if you write it in perl, you have to put it in your cgi-bin which automatically means it's a dynamically generated page? security by obscurity . Is this true or hardly means anything? thx!
15
2689
by: Good Man | last post by:
Hey there I have a dumb question.... Let's say i have a database full of 4000 people.... I select everything from the database by: $result = mysql_query("SELECT * FROM People");
2
1924
by: Tim | last post by:
Maybe I've been working too long, but has anyon had their python interpreter stop taking commands. The IDLE version works fine, but under Windoze: 1) execute "python" in teh command shell 2) ...interpreter comes up fine 3) type in anything and you get "SyntaxError: invalid syntax" Literally, you could type in "import sys" or anything common and you get the
4
1419
by: Aubrey Hutchison | last post by:
I have exhausted places to look for where "PYTHONPATH" is located.. In windows (using the DOS command) no such thing exist but path does. I find no file with that name. I have yet to find a config file that I would think might work as PYTHONPATH. What am I missing? Thanks
4
3440
by: Python Dunce | last post by:
I've run into an issue with glob and matching filenames with brackets '' in them. The problem comes when I'm using part of such a filename as the path I'm passing to glob. Here's a trimmed down dumb example. Let's say I have a directory with the following files in it. foo.par2 foo.vol0+1.par2 foo.vol1+1.par2 zzz .par2 zzz .vol0+1.par2
8
1612
by: Fred Hebert | last post by:
I have a function that requires a LPCTSTR parameter. I have the value I want to pass to it in a TextBox->Text field. Is there any way to do it in a single assignment. e.g. DWORD Xyz::TheFunc(LPCTSTR lpVal) .... TheFunc(Junk->Text->Something());
2
2227
by: Bill Nguyen | last post by:
I would like to add a new VB.NET project using the same folder being used by another project so that I can share several forms already creaded by the other project. However, .NET created a new folder using whatever project name I supplied. Is there a work around for this? Thanks Bill
16
1652
by: CMM | last post by:
Is it me or has anyone noticed that F1 is really dumb in VS2005. Since VB3 I have been able to click F1 on an ambiguous method in code and the IDE automatically determines the type based on the code itself and shows the right help topic. This even worked more or less in VS2003. But in VS2005, if I highlight the "Host" method below and hit F1 I get a help topic on the "UriBuilder.Host" property. Huh????? That's dumb. Dim o as New...
3
1163
by: Nonee | last post by:
Ok ok... I have been staring at this for a generation or so now and it is not working. And it is something really simple too. I have a listbox of mp3s (flbMp3s). I have a textbox (txtSearch). I have the directory of the mp3s (System.IO.Directory.GetFiles). I want to search the directory from the text in the textbox, adding to the listbox if there is a match. I have tried file.IndexOf(txtSearch.Text), file.Contains(txtSearch.Text),...
0
9666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10142
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9986
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5422
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4093
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.