Hi,
in my win application I've a file named myFile.xml at the root of my
application: in debug mode, when I try to read this file, the runtime
application searches it in the path bin/debug... and it doesn't find it
because there isn't there, so I've used the function:

Path.GetFullPath("../../myFile.xml")

thanks to this function it works, but when I try to deploy the application,
it doesn't work anymore, because path is different... How can I set a
flexible path at the deployment and in my code?

Please help me.

Re: PATH in Debug mode by Morten

Morten
Tue Apr 26 05:14:36 CDT 2005

Hi Siu,

Well, you could store the path to the file in the registry, a local config file or in UserAppDataPath etc.


--
Happy coding!
Morten Wennevik [C# MVP]

RE: PATH in Debug mode by DavidIAGrant

DavidIAGrant
Tue Apr 26 06:33:02 CDT 2005

Hello,

From the project property pages -> Common properties -> Build events you can
set a Post-build Event Command line to something like this:

copy "$(SolutionDir)myFile.xml" "$(TargetDir)myFile.xml"

This means that you can always assume that the file will be in the root
directory of your application.

Hope this helps,

David

"Siu" wrote:

> Hi,
> in my win application I've a file named myFile.xml at the root of my
> application: in debug mode, when I try to read this file, the runtime
> application searches it in the path bin/debug... and it doesn't find it
> because there isn't there, so I've used the function:
>
> Path.GetFullPath("../../myFile.xml")
>
> thanks to this function it works, but when I try to deploy the application,
> it doesn't work anymore, because path is different... How can I set a
> flexible path at the deployment and in my code?
>
> Please help me.

Re: PATH in Debug mode by Herfried

Herfried
Tue Apr 26 12:11:31 CDT 2005

"Siu" <Siu@discussions.microsoft.com> schrieb:
> in my win application I've a file named myFile.xml at the root of my
> application: in debug mode, when I try to read this file, the runtime
> application searches it in the path bin/debug... and it doesn't find it
> because there isn't there, so I've used the function:
>
> Path.GetFullPath("../../myFile.xml")
>
> thanks to this function it works, but when I try to deploy the
> application,
> it doesn't work anymore, because path is different... How can I set a
> flexible path at the deployment and in my code?

In Windows Forms applications you can use 'Application.StartupPath', in
console applications/class libraries you can use the code below:

\\\
Imports System.IO
Imports System.Reflection
.
.
.
Private Function ApplicationPath() As String
Return _
Path.GetDirectoryName([Assembly].GetEntryAssembly().Location)
End Function
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>