473,659 Members | 3,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding ASP.NET temporary directory

Hi,

I am looking for a way to discover the path to the ASP.NET temporary
directory, which is called something like 'Temporary ASP.NET Files'.

From within an ASP.NET application, I can get the path using
IO.Path.GetTemp Path(), but I need to do so from outside the application.
I am currently using a web service for this, but this is a less than
optimal solution: if the web service is unable to start, I don't get the
full error message from IIS.

Is there any way to ask ASP.NET what its temporary directory is?

Thanks,
Rik

Feb 15 '06 #1
2 17266
The temp directory is hard-coded.

For .Net Framework 2.0 :
bootdrive:\%win dir%\Microsoft. NET\Framework\v 2.0.50727\Tempo rary ASP.NET Files

For .Net Framework 1.1 :
bootdrive:\%win dir%\Microsoft. NET\Framework\v 1.1.4322\Tempor ary ASP.NET Files

This is a real hack, but it will retrieve the Temp directory path programmaticall y :

In global.asax :

Sub Application_OnS tart()
Dim MyArray() As String = Split(AppDomain .CurrentDomain. DynamicDirector y, "\")
Application("TE MP_DIR") = (MyArray(0).ToS tring() & "/" & MyArray(1).ToSt ring() & "/" _
& MyArray(2).ToSt ring() & "/" & MyArray(3).ToSt ring()) & "/" & MyArray(4).ToSt ring() & "/" _
& MyArray(5).ToSt ring())
End Sub

The path to the machine's ASP.NET Temporary Files directory
is now contained by Application("TE MP_DIR").

You can probably parse MyArray(), to extract the temp dir,
in a far simpler way, but I didn't have the time to do that for you right now.

What you need to do is strip off MyArray(6), MyArray(7) and MyArray(8) from the
string array created by Split(AppDomain .CurrentDomain. DynamicDirector y, "\").

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== =====
"Rik Hemsley" <ri*@rikkus.inf o> wrote in message news:el******** ******@TK2MSFTN GP12.phx.gbl...
Hi,

I am looking for a way to discover the path to the ASP.NET temporary directory, which is called
something like 'Temporary ASP.NET Files'.

From within an ASP.NET application, I can get the path using IO.Path.GetTemp Path(), but I need to
do so from outside the application. I am currently using a web service for this, but this is a
less than optimal solution: if the web service is unable to start, I don't get the full error
message from IIS.

Is there any way to ask ASP.NET what its temporary directory is?

Thanks,
Rik

Feb 15 '06 #2
Juan T. Llibre wrote:
The temp directory is hard-coded.


Sorry, I meant the 'other' temp directory, not the 'Temporary ASP.NET
files' one. I'm not completely sure what this other directory is used
for, but I know that I need to give write access to it to the user who
the web application runs as, or I get 'permission denied' errors.

When a web _service_ is running, IO.Path.GetTemp Path() returns (for me):

C:\DOCUME~1\RIK \ASPNET\LOCALS~ 1\Temp\

RIK\ASPNET seems to be name-of-machine\ASPNET, rather than username\ASPNET .

Looking at it again, I think it might be quite easy to work out what
this path will be, without having to be a web service, so I'll give it a
go and see if I can figure out a correct implementation.

BTW for anyone wanting to get the 'Temporary ASP.NET files' directory
from outside the web application, I do it like this:

String.Format _
( _
"{0}\Microsoft. NET\Framework\v {1}.{2}.{3}\Tem porary ASP.NET Files", _
Environment.Get EnvironmentVari able("windir"), _
Environment.Ver sion.Major, _
Environment.Ver sion.Minor, _
Environment.Ver sion.Build _
)

Cheers,
Rik
Feb 16 '06 #3

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

Similar topics

11
2377
by: Fuzzyman | last post by:
What's the best, cross platform, way of finding out the directory a script is run from ? I've googled a bit, but can't get a clear answer. On sys.argv the docs say : argv is the script name (it is operating system dependent whether this is a full pathname or not). So this doesn't seem to be the answer.
1
3842
by: Sugapablo | last post by:
How can I find out the full directory path (i.e. c:\path\to\file) of a file? I'm logged into a server and the of course, I have an FTP directory root, but I need to know the absolute path. -- http://www.sugapablo.com <--music ] http://www.sugapablo.net <--personal ]
1
4093
by: Bruce | last post by:
I am writing an installer that needs to put a dll file with a bunch of extended stored procedures in the BINN directory. The problem is that if the machine is running multiple instances of SQL Server, there is more than one BINN directory. The installer has a dynamically populated dropdown with the name of the instances, so does anyone know if this logic is correct and/or reliable assuming SQL Server 2000? If the instance name =...
4
3675
by: Advocated | last post by:
Just wondering, is there a way to find the current directory? well, i mean whats the best way to go about it? Cheers
2
1369
by: JH | last post by:
I want to do a custom setup using some files after installing my application? How do I get the directory where my application is installed? Can some one please help me with the code New to VB here
2
3673
by: Steven J. Reed | last post by:
I have a Web Service that needs to find a Virtual Directory name, determine the actual path of that directory, then read / write files to that directory. How can I find a virtual directory then determine it's properties?
6
1975
by: Sigmathaar | last post by:
Hi, while making an XML parser for the creation of an entire directory list I got this problem and I'm having trouble solving it. The program (not yet written) goes through an XML Schema Instance to create some directories (about 5000). While creating the directories the XML file that I'm parsing is alphabetically ordered not hierarchically and I can't allow the program to stock the path names for each brach on the directory tree. The...
0
1341
by: SP | last post by:
Dear all! I have written a web service which should archive files in a server directory. The files are placed in a directory that the web server can access. In the first step I copy them to a temporary directory on the web server. Afterwards I put some data into a database table and put one of the files into a content management system by sending an e- mail. If all that works fine I have to copy the files from the temporary folder into...
1
1129
by: ngrTerry | last post by:
My program requires that I need to locate the temporary directory of the currently logged on user. Please caould someone tell ne in VBNET2005 how this could be best achieved. Many thanks in advance for feedback. Terry
0
8337
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8748
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8531
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8628
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7359
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2754
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.