AdamM wrote:
How can an app detect whether its running under debug or release mode
and update file paths automatically?
I have several hardcoded paths like "c:\app\bin\deb ug" currently and
want to make it more robust.
Thanks!
Adam
Hi Adam,
use Application.Sta rtupPath to determine the directory. Now there are
two ways (Well, actually there are some more :-) ) to handle the paths:
->Make all you hardcoded paths relative to your application directory,
e.g.: ..\..\Data. Use Path.Combine to build a valid Path when you need it.
string path =
Path.GetFullPat h(Path.Combine(
Application.Sta rtupPath, @"..\..\Data ")
);
->store all you data under thhe current or the all user profile. You can
get the path like this:
string curUserProfile =
Environment.Get FolderPath(Envi ronment.Special Folder.Applicat ionData);
string allUserProfile =
Environment.Get FolderPath(Envi ronment.Special Folder.CommonAp plicationData);
You might want to evaluate to use the isolated storage mechanims, too.
HTH,
Andy
--
To email me directly, please remove the *NO*SPAM* parts below:
*NO*SPAM*xmen40 @*NO*SPAM*gmx.n et