473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

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


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("myF ile.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
Nov 19 '05 #1
2 6763
Just using Server.MapPath() wont work to retrieve the server file?

What does it return?

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Sakharam" wrote:

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("myF ile.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

Nov 19 '05 #2

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

"Curt_C [MVP]" <software_at_darkfalz.com> wrote in message
news:62**********************************@microsof t.com...
Just using Server.MapPath() wont work to retrieve the server file?

What does it return?

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Sakharam" wrote:

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("myF ile.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

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: John Rebbeck | last post by:
I've got the directory f:\Company\Product set as web shared so it's got a virtual directory in the default web site on my test server's IIS. If I try to use Server.MapPath in that site it returns a...
0
by: jimmy | last post by:
Hoping someone can help. I've setup several FTP shares on IIS 5, where some of the shares are located on another computer, while other directories are on the local computer. Is there a...
1
by: Michiel Schaeverbeke | last post by:
Hi, I'm trying to reach an xml file from within a web application. The file is physically on a different server. When I try to reach it using \\servername\path\ style, I get the error...
8
by: dw | last post by:
Hello, all. I have a site that I'm testing on my LOCALHOST and also on a remote server, depending on whether I'm at work or at home. I don't want the OLEDBDATAAdapter to be pointing to the remote...
1
by: Raed Sawalha | last post by:
I have a problem in getting asp.net application physical path in global.ascx static function in my global.ascx i have a static function : first i tried to get the physical path by refelection...
8
by: Jaime Stuardo | last post by:
Hi all... How can I get the physical path of a web site from an EXE application? The Web Site is on the same server as the application. Thanks in advance Jaime
8
by: Samuel Shulman | last post by:
Hi all I would like to reference a file in a class in the 'App_Code' folder and I wanted to use the server.MapPath property How can I do that? Samuel
4
by: =?Utf-8?B?SmVmZiBCZWVt?= | last post by:
Best way I can think to describe this is through an example. I have a virtual directory, let's call it "MyVirtualDirectory" that maps to \\MyServer\Shared. I have a path that is...
5
by: marss | last post by:
Server.MapPath("~/page.aspx") returns the physical file path based on the specified virtual path. Is there any reverse method to get the virtual path based on the physical path (both pathes belong...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.