HttpContext.Current.Server null

后端 未结 3 1499
别那么骄傲
别那么骄傲 2020-12-07 02:15

I have a windows service which is using a method from a class library with same asp.net solution. in class library, I have a method with following line:

 re         


        
3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-07 02:44

    It could be that when you are using windows service, you are no longer running a web app, therefore HttpContext and web server is not available. Try using System.IO.File for mapping, see whether that takes you to the correct directory.

    Edit

    private String yourFullPath = System.IO.Path.GetFullPath("/YourDirectory") + @"\";
    

提交回复
热议问题