Runtime can not find xml files

Greetings,
I have a windows application that runs great in Debug/release mode.  I compile the setup.exe file using Inno Script Tool and include the xml files in the code.  When I run the setup.exe file the exe file is created in the proper directory along with the xml files.  So I know the files make it this far.

When I run the exe it does not find the xml files.

Below are some code snippets of how I am reading the xml files

In general declarations
Public path As String

Open in new window


In form load
path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)

Open in new window

       
In the button action
        ai_weights.vm1_read_file()

Open in new window


In ai_weights.vm1_read_file
      Dim f As String = path & "\ai_tuning_vm1.xml"
      If (IO.File.Exists(f)) Then

Open in new window


When I break at the If ... Then statement the path is correct when I point at f string and as I said it works in debug mode

Thanks for the help,
Ron Wensley
rwensleyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jacques Bourgeois (James Burger)PresidentCommented:
If this code is in a .exe, simply use Application.ExecutablePath to retrieve the directory in which the application is installed.

If it is in a .dll, then you should go for GetCallingAssembly or GetEntryAssembly (depending on how the method is called) instead of GetExecutingAssembly.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bob LearnedCommented:
For Windows Forms, what does Application.StartupPath return?
0
Jacques Bourgeois (James Burger)PresidentCommented:
By default, Application.StartupPath returns the same thing as the Application.ExecutablePath.

But if you create a shortcut to start the application, you can define a different StartupPath. Just right click on an application shortcut, and you will see a "Start in" option. This can be used to specify a default directory for data files that is different than the application directory.

But since the application .config file is in the application directory if you use the default configuration mechanism, ExecutablePath is most appropriate in most situations. If you were using StartupPath with the .config file, you would end up with exceptions at the launch of the application if a user ended up fooling around with the shortcut that launch it.
0
Bob LearnedCommented:
I don't use Windows Forms very much any more, so I was curious if there was a case where the two would be different, like from a unit test project...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.