0

I'm building a web service in Visual Studio. When running the service, a machine learning model save on local disk needs to be loaded to memory. However, when the service is deployed, the file path is changed that I can not load the file by the relative path I defined in code. I'm now using HttpContext.Current.Server.MapPath() to get my path mapped at run time. I'm wondering if there is more elegant way to fix the path at building or deploying time.

Thanks, Juhua

eigen
  • 95
  • 1
  • 8

1 Answers1

0

Related Question

You can try the following:

static void Main(string[] args)
{
    if (args.Length == 0)
    {
         Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
                RunAsService();
    }
    else
    {
        RunAsConsole();
    }
 }
Gaurang Dave
  • 3,956
  • 2
  • 15
  • 34
user2404597
  • 488
  • 4
  • 18