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.
Morten Wennevik - 26 Apr 2005 11:14 GMT
Hi Siu,
Well, you could store the path to the file in the registry, a local config file or in UserAppDataPath etc.

Signature
Happy coding!
Morten Wennevik [C# MVP]
David I A Grant - 26 Apr 2005 12:33 GMT
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
> Hi,
> in my win application I've a file named myFile.xml at the root of my
[quoted text clipped - 9 lines]
>
> Please help me.
Herfried K. Wagner [MVP] - 26 Apr 2005 18:11 GMT
"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
[quoted text clipped - 7 lines]
> 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
///

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