Results 1 to 9 of 9

Thread: Application.startuppath

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    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

  2. #2
    Lively Member
    Join Date
    Mar 2006
    Posts
    69

    Re: Application.startuppath

    Did you print Application.StartupPath to confirm that it infact is: "C:\CodeRed6" ?
    2B || !2B

  3. #3
    Hyperactive Member
    Join Date
    May 2006
    Posts
    426

    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"

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Application.startuppath

    Surely Application.StartupPath will be returning "C:\CodeRed6\CodeRed_1_0_0_10".
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Hyperactive Member josep's Avatar
    Join Date
    Sep 2006
    Location
    Barcelona
    Posts
    409

    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:
    1. If not Application.StartupPath.EndsWith("\") Then
    2.              fileMap.ExeConfigFilename = Application.StartupPath & "\"
    3.         End If
    4. fileMap.ExeConfigFilename &= "CodeRed6\CodeRed_1_0_0_10\CodeRed.exe.config.deploy"

    Hope this helps
    Useful links:DB connection strings ADO.NET VB.NET Tutorials

    • Don't forget to close the thread if solved
    • If this post helps you rate it

  6. #6
    Hyperactive Member
    Join Date
    May 2006
    Posts
    426

    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.

  7. #7
    Hyperactive Member josep's Avatar
    Join Date
    Sep 2006
    Location
    Barcelona
    Posts
    409

    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
    Useful links:DB connection strings ADO.NET VB.NET Tutorials

    • Don't forget to close the thread if solved
    • If this post helps you rate it

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    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
    steve

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width