Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

application.startuppath 1

Status
Not open for further replies.

steve1rm

Programmer
Aug 26, 2006
255
GB
Hello,

I want to be able to edit a file. The file will be located in the same directory as the setup.exe. However when the program is run it does work when i use the application.startupath. However, when I don't use it works ok. Can anyone explain how this should work.

Code:
fileMap.ExeConfigFilename = Application.StartupPath & "\CodeRed6\CodeRed_1_0_0_10\CodeRed.exe.config.deploy" 'Not work
            fileMap.ExeConfigFilename = "C:\CodeRed6\CodeRed_1_0_0_10\CodeRed.exe.config.deploy" 'Works ok

            config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None)

Many thanks in advance,

Steve
 
Check your startup path it may have the "\bin" with it.
djj
 
Steve, try using the Application.LocalUserAppDataPath.
 
Thanks guys,

problem solved before:

Code:
Dim path As String
            path = Application.StartupPath & "\CodeRed_1_0_0_6\" & "CodeRed.exe.config.deploy"
            fileMap.ExeConfigFilename = path

Thanks,

Steve
 
Hello,

I thought I had this resolved.

The problem is this. I have deployed a program in the folder where the setup file is, I have a folder called CodeRed_1_0_0_10, inside that folder I have a file called CodeRed.exe.config.deploy. I want to be able to access this file.
The path is this:
C:\Deployed_4_10_06\CodeRed_1_0_0_10.

The setup.exe file is located in the Deployed_4_10_06 folder. I thought by using application.startuppath would point to this directory. However, after checking I found out that is points to this one below:

C:\Documents and Settings\yasin\Local Settings\Apps\2.0\YDBGO2AL.YA3\TOMO6HER.GJR\code..tion_53e3de40adb22891_0001.0000_adfb41cfb825f353

I thought by using this:
path = Application.StartupPath & "\CodeRed_1_0_0_11\" & "CodeRed.exe.config.deploy"

I would be able to update my file, but cannot not.

Is there a way to be able to point to the file where the setup.exe is located?

Many thanks in advance,

Steve
 
Hello Rjoubert,

I tried Application.localUserAppDataPath. Still the same problem as I stated above.

Do you know of any other solution?

Thanks for your time,

Steve
 
How are you running the setup.exe? Do you go to the file in C:\Deployed_4_10_06\ and double click setup.exe or are you clicking install from the setup project?

Application.StartupPath returns the exact location the program calling it is running from. So if you use install off of the setup project it is going to run it from the location the project was saved in. I cannot say for sure, but that looks like a path that Application.LocalUserAppDataPath would return. Which is the current login users Application Data Path. If the setup is run in the folder it should have returned as you thought "C:\Deployed_4_10_06".

Another question is your program seems certain that the program is going to be under the folder "\CodeRed_1_0_0_11\". Is the setup program creating the file structure and then the last thing you want it to do when finished is run that program?

-I hate Microsoft!
-Forever and always forward.
 
Hello Sorwen,

Thanks for your reply.

The files and folders I have in Deployed_4_10_06 are all the files that were created when the program was published:
CodeRed_1_0_0_10 - folder
CodeRed - file
CodeRed_1_0_0_10 - file
setup.exe - file

The CodeRed.exe.config.deploy is located in the CodeRed_1_0_0_6 folder.

What I am doing is clicking on the setup.exe a form will be displayed what will allow the user to updated the config.file. The problem is I am having trouble getting the path to that folder.

Any ideas,

Thanks in advance,

Steve

 
Are you using the Publish Wizard to publish the setup.exe? The "One Touch" Solution (or whatever it is called).

-I hate Microsoft!
-Forever and always forward.
 
Hello Sorwan,

Yes I have used the clickonce, which is available in .Net 2005.

Steve
 
That is the problem. Click Once installs the program in two parts. The place the application actually runs from is the Application Data Path. That why you get the information the same whether you use Application.localUserAppDataPath or Application.StartupPath. It is the same place in this instance. Unfortunately I don't know how to help you fix this. What I had to do was totally abandon the Click Once and go to a setup project for initial install. While there maybe other choices the only other things I could suggest is hard coding it or make sure the "\CodeRed_1_0_0_11\" sub folder is place in that location given (C:\Documents and Settings\yasin\Local Settings\Apps\2.0\YDBGO2AL.YA3\TOMO6HER.GJR\code..tion_53e3de40adb22891_0001.0000_adfb41cfb825f353).

-I hate Microsoft!
-Forever and always forward.
 
Hello Sorwan,

Thanks for your help. Looks like I will have to go for setup project instead of the click-once and hope that works.

Will the setup project make this able to be done?

Thanks for you help,

Steve
 
The quick answer is yes. The problem is I a little confused on the bigger picture. You have a program called setup that opens "CodeRed.exe.config.deploy". Maybe I'm being mislead by what you are calling your program setup, but you would then be making a setup program to install your setup program. You shouldn't need to do that. Perhaps a little bit more on what you are doing and I could help you better. I know about the pathing because I've spent a lot of time working on it (and a few things related to it), but my knowledge is limited compare to others that might be able to help you with more info.

Some questions I would ask are why does the setup program want to write to "CodeRed.exe.config.deploy"? What kind of information is it writing? Does it write data for another program to use once it runs? Does the file already exist or are you creating it a little earlier in the code? What is the setup program setting up when it isn't writing to the file? If a new version is created will a new setup have to write to the exact same file or is it only needed at the time setup.exe is ran?


-I hate Microsoft!
-Forever and always forward.
 
Hello Sorwen

Thanks for your the information.

Well finding the path was just a little bit of a bigger problem.

I have 2 deployed programs. 1 is called a CodeRedSetupWizard. All all this does is run a form that will allow the user to input thier connection settings. The customer does not know until they install the application which server they will connect to.

After this, the customer will select next and this will call the setup.exe that will install the codeRed application.

using this: Shell(Application.StartupPath & "\setup.exe", AppWinStyle.NormalFocus, True)

The codeRed program will install with the connection setting already updated in the CodeRed.exe.config.deploy file.

When I published both project (setupWizard and codeRed) I put all the files and folder into the same directory. I renamed the setupWizard's setup.exe as installCodeRed.exe.

So they would double click installCodeRed.exe fill out the connection settings and update the config file, and then call the setup.exe to install the CodeRed application.

Everything works, apart from being able to find the folder CodeRed_1_0_0_11.

Just to make things clear I have these in my folder. published files:
CodeRed_1_0_0_11 - folder
CodeRedSetupWizard_1_0_0_9 - folder
CodeRed - file
CodeRed_1_0_0_11 - file
codeRedSetupWizard - file
CodeRedSetupWizard_1_10_0_9 - file
InstallCodeRed.exe - file
setup.exe - file

I am not sure if this is the best way to do this. But I am new at this, and have managed to get everything working, and only finding the right folder form the application.startuppath.

Hope you can help me further.


Thanks very much for you time,

Steve

Steve



 
There are ways you could do this with just one setup (setup project), but since I've not tried them myself I couldn't help there. So I say if it is working for you go for it. Someone else may be able to give better suggestions there.

I'm going to make a few assumptions from what you said at first. First a setup project does sound like what you need. What you would then do is have the that setup install your wizard and the setup. That would put both into a path your wizard and setup can read from with the Application.StartupPath.

If you have Microsoft Document Explorer installed the link for a great walk through on creating a setup project is here: ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_deploy/html/02cbce50-6fc2-4b89-bc32-3720a7651087.htm

If not I'll have to check my old posts as there is a way to change that url to one for the MSDN Library.

Some additional suggestions/questions:

1) I would suggest having the setup project start the wizard so the customer doesn't have to go looking for it. I've not tried this, but if I remember right there is a post or FAQ here that will explain how to do that and I'll help where I can.

2) If the setup wizard doesn't need to run again or should never be run again then I would suggest having the setup project install to a temp directory and then the directory be deleted after the install is finished. The only problem is I have no clue how to do this so....

3) I assume that the setup.exe sets up certain parts of the program or adds other programs based on the CodeRed.exe.config.deploy?


-I hate Microsoft!
-Forever and always forward.
 
Hello Sorwan,

I found a good solution using clickonce. Using the following code:

Code:
If (System.Deployment.Application.ApplicationDeployment.CurrentDeployment.IsFirstRun)) Then
            Dim setConnection As New ServerSettings()
            setConnection.Show()
        Else
            Dim logMeIn As New Login()
            logMeIn.Show()
        End If

However, the customer has just changed their mind. And they they want to specify the location of where they want to install the application. Clickonce only has a default that cannot be changed.

So I using the ms installer. However the above code does not work for it. It seems I am destined not to get this finished.

I would like the serverSettings to run only on first startup. However, I am not sure about the code for this, as the above does not work.

Do you know the synstax for first run when using ms installer?

Many thanks for your help,

Stteve
 
Sorry, I don't know.

-I hate Microsoft!
-Forever and always forward.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top