How to get physical path of file? MapPath() - Scheduler - Thread

S

Sakharam

Hi All,

I am developing a scheduler object for my web application. I am starting new
thread on Application_Start event.
Everything works fine except following issue.
I am using following statement in it to get physical path of file.

strTemplateFile =
System.Web.HttpContext.Current.Server.MapPath("myFile.txt")

But, Since thread is not running against any request, I can't get
HttpContent.Current object and it throws NullReference Exception.
When I start scheduler from web page it works fine.

Can anyone guide me how to achieve this when code runs on Application_start
event not against any request.

Any help will be appreciated.

Thanks and Regards,

Sakharam Phapale
 
G

Guest

Just using Server.MapPath() wont work to retrieve the server file?

What does it return?
 
S

Sakharam

Hi Curt,

Thanks for reply.

Since this is simple class, I cannot use simply "Server.MapPath".
Note that this class function gets called from "Application_Start" event in
seperate thread.

Thanks and Regards,

Sakharam Phapale
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top