Friday, April 1, 2011

Difference Between Environment.CurrentDirectory And Application.ExecutablePath

here i am using simple windows application.

steps:

1) Create Simple Windows Application using VB.net 2.0.

2) put the button (id=button1) on the form.

3) On the Button Click Event put the below code.

Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
'get the EnvironmentPath
MsgBox(" EnvironmentPath " & Environment.CurrentDirectory.ToString())
'get the application path
Dim str As String = Application.ExecutablePath.Substring(0, Application.ExecutablePath.LastIndexOf("\"))
MsgBox(" ApplicationPath " & str)End Sub4) output of this Application.

EnvironmentPath : Your Application Path + \bin\Debug

ApplicationPath : Your Application Path + \bin\Debug

here both are same.

5) Create a *Set Up Project and install the set up in to your computer.

EnvironmentPath : Your Drive + Documents and Settings\ + UserFolder

ApplicationPath : Your Drive + Documents and Settings + UserFolder + \Start Menu\Programs

the above path is different.

when you use any file or report path and at that time if you use the EnvironmentPath that will give error.

*Set Up Project :

create set up project using the dotnet i give hint ( Open File Menu : Create New Project

–> Select Other Project Types

–> Set Up And Deployment (select Setup Project).

--
Happy coding..

No comments: