Sunday, January 13, 2013

Developer Tip When Getting Absolute Path for .NET Applications

When obtaining the executing path for a .NET application which could be used from Web, Windows and Console Application, developer should be careful that Web applications work differently than a Windows or Console Application.

The code

System.AppDomain.CurrentDomain.BaseDirectory

Should be used carefully since in a web application there is no concept of debug / release within the bin directory, that is present in a Windows/Console application based on the build configuration. Either "debug" or "release" directory gets added automatically when you are in Visual Studio.  This is again different when we host the application where we can have only bin directory once we deploy the Windows / Console Application. Care should be taken to account for this when we write common code.

No comments:

Post a Comment