473,520 Members | 3,076 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.GetTempPath(), 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 17250
The temp directory is hard-coded.

For .Net Framework 2.0 :
bootdrive:\%windir%\Microsoft.NET\Framework\v2.0.5 0727\Temporary ASP.NET Files

For .Net Framework 1.1 :
bootdrive:\%windir%\Microsoft.NET\Framework\v1.1.4 322\Temporary ASP.NET Files

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

In global.asax :

Sub Application_OnStart()
Dim MyArray() As String = Split(AppDomain.CurrentDomain.DynamicDirectory, "\")
Application("TEMP_DIR") = (MyArray(0).ToString() & "/" & MyArray(1).ToString() & "/" _
& MyArray(2).ToString() & "/" & MyArray(3).ToString()) & "/" & MyArray(4).ToString() & "/" _
& MyArray(5).ToString())
End Sub

The path to the machine's ASP.NET Temporary Files directory
is now contained by Application("TEMP_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.DynamicDirectory, "\").

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.info> wrote in message news:el**************@TK2MSFTNGP12.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.GetTempPath(), 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.GetTempPath() 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}\Temporar y ASP.NET Files", _
Environment.GetEnvironmentVariable("windir"), _
Environment.Version.Major, _
Environment.Version.Minor, _
Environment.Version.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
2360
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
3831
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
4081
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...
4
3665
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
1363
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
3658
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
1972
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...
0
1336
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...
1
1116
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
7325
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7237
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...
0
7629
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...
0
7591
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...
1
5158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3298
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...
0
3298
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
531
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.