Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

get application path in .NET

  • 01-03-2006 9:56am
    #1
    Registered Users, Registered Users 2 Posts: 4,100 ✭✭✭


    Ok, i've got a web application in .NET. It consists of a c# class library which encompases all the core functionality of the application, and an ASP.NET interface. The ASP.NET project uses the class library for it's functionality.

    The class library contains a log class for writing errors to a log. At the moment I have the path of the log file hard coded, but what I want it to do is create the log file in whatever directory the ASP.NET project is running in. So far I've tried System.AppDomain.CurrentDomain.BaseDirectory, Application.ExecutablePath, and Application.StartupPath but none give me the path I need.

    Does anyone know if it's possible to obtain the path of the ASP.NET app that references the class library, and if so, how?


Comments

  • Registered Users, Registered Users 2 Posts: 2,758 ✭✭✭Peace


    Petr wrote this class...
    	public class App
    	{
    		public App()
    		{
    			//
    			// TODO: Add constructor logic here
    			//
    		}
    		public static string AppPath()
    		{
    			return System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
    			//return System.Windows.Forms.Application.StartupPath;
    
    		}
    
    
    	}
    

    I've commented out the Forms line as its not really applicable to your ASP stuff i believe.

    <edit>
    I forgot to mention that it works for any of the webservices we are using...
    </edit>


  • Registered Users, Registered Users 2 Posts: 4,100 ✭✭✭muckwarrior


    Nice one. Just realised that I think I actually already had it working at one stage but didn't realise it because I forgot to publish the web project so it was giving me the debug path :o .


  • Moderators, Science, Health & Environment Moderators Posts: 9,035 Mod ✭✭✭✭mewso


    server.MapPath(request.ApplicationPath)


Advertisement