Getting full path for Windows Service

后端 未结 7 1174
感情败类
感情败类 2021-01-31 01:22

How can I find out the folder where the windows service .exe file is installed dynamically?

Path.GetFullPath(relativePath);

returns a path base

7条回答
  •  萌比男神i
    2021-01-31 02:07

    Another version of the above:

    string path = Assembly.GetExecutingAssembly().Location;
    FileInfo fileInfo = new FileInfo(path);
    string dir = fileInfo.DirectoryName;
    

提交回复
热议问题