|
-
Oct 4th, 2006, 06:57 AM
#1
Thread Starter
Frenzied Member
Application.startuppath
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
Last edited by steve_rm; Oct 4th, 2006 at 10:52 PM.
steve
-
Oct 4th, 2006, 07:10 AM
#2
Lively Member
Re: Application.startuppath
Did you print Application.StartupPath to confirm that it infact is: "C:\CodeRed6" ?
-
Oct 4th, 2006, 07:11 AM
#3
Hyperactive Member
Re: Application.startuppath
Is the return type for ExeConfigFilename as string?
If it is, try
fileMap.ExeConfigFilename = ".\CodeRed6\CodeRed_1_0_0_10\CodeRed.exe.config.deploy"
-
Oct 4th, 2006, 07:25 AM
#4
Re: Application.startuppath
Surely Application.StartupPath will be returning "C:\CodeRed6\CodeRed_1_0_0_10".
-
Oct 4th, 2006, 07:29 AM
#5
Hyperactive Member
Re: Application.startuppath
According your code I assume your exe is on the
C:\
if that's true application.startuppath returns you c:\
so your path is
c:\\CodeRed6\CodeRed_1_0_0_10\CodeRed.exe.config.deploy
which returns you an error
Try that
VB Code:
If not Application.StartupPath.EndsWith("\") Then
fileMap.ExeConfigFilename = Application.StartupPath & "\"
End If
fileMap.ExeConfigFilename &= "CodeRed6\CodeRed_1_0_0_10\CodeRed.exe.config.deploy"
Hope this helps
-
Oct 4th, 2006, 07:37 AM
#6
Hyperactive Member
Re: Application.startuppath
JMC has given you the right answer. You need to just append it with the string of your file name.
Disregard what i wrote earlier.
-
Oct 4th, 2006, 07:42 AM
#7
Hyperactive Member
Re: Application.startuppath
Hi again
As usual JMC points on the right direction 
Just check this tread (or have a look on the help) to know what is returning the startuppath method and concatenate the right string to get the path (or file) relative to startuppath of you application
-
Oct 4th, 2006, 10:51 PM
#8
Thread Starter
Frenzied Member
Re: Application.startuppath [*Resolved *]
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
-
Oct 4th, 2006, 10:55 PM
#9
Re: Application.startuppath
It looks very much like you're publishing your app using ClickOnce. One of the advantages of ClickOnce is that it has in-built auto-update functionality. You should head to MSDN and read up on ClickOnce and what it can and can't do.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|