Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / April 2005

Tip: Looking for answers? Try searching our database.

PATH in Debug mode

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Siu - 26 Apr 2005 10:49 GMT
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/>


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.