473,414 Members | 1,737 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,414 software developers and data experts.

Best way to get temp directory without PInvoke?

Staying in managed code, what is the best way to get the temp directory
in C# .NET programming? I'm currently using this:

public static String GetTempDir()
{
return Environment.GetEnvironmentVariable("TEMP");
}

I wonder, is there a better solution? This one feels a little system and
OS dependant to me.

Thanks.

- Charlie

Nov 16 '05 #1
2 21511
Hi Charlie,

You could try the GetTempPath() static method in the Path class
in the System.IO namespace.

String tempFolderPath = Path.GetTempPath();

Regards,
Aravind C
"Charlie Calvert" <ch**********************@elvenware.com> wrote in message
news:uX**************@TK2MSFTNGP11.phx.gbl...
Staying in managed code, what is the best way to get the temp directory
in C# .NET programming? I'm currently using this:

public static String GetTempDir()
{
return Environment.GetEnvironmentVariable("TEMP");
}

I wonder, is there a better solution? This one feels a little system and
OS dependant to me.

Thanks.

- Charlie

Nov 16 '05 #2

http://www.knowdotnet.com/articles/tempfiles.html
--
W.G. Ryan MVP Windows - Embedded

http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/
"Charlie Calvert" <ch**********************@elvenware.com> wrote in message
news:uX**************@TK2MSFTNGP11.phx.gbl...
Staying in managed code, what is the best way to get the temp directory
in C# .NET programming? I'm currently using this:

public static String GetTempDir()
{
return Environment.GetEnvironmentVariable("TEMP");
}

I wonder, is there a better solution? This one feels a little system and
OS dependant to me.

Thanks.

- Charlie

Nov 16 '05 #3

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

Similar topics

1
by: Jason Charalambides | last post by:
Hi, I wanted to do the following: 1. Save a file as "Tensegrity.tmp" in my C:\Temp directory (and if one exists to replace it without any interaction, asking me about it etc.) 2. Once this is...
4
by: Frank Millman | last post by:
Hi all I need to generate potentially large reports from a database, and I want to offer the option of print preview before actually printing (using wxPython). I figure that the best way to...
5
by: Andrew S. Giles | last post by:
I thought I would post here, as I am sure someone, somewhere has run into this problem, and might have a good solution for me. I am writing an applicaiton in C# that will accept data and then put...
10
by: robwharram | last post by:
Hi, I'm quite frustrated in the fact that I can't even display a simple "Hello World" message on .Net. I've been through all of the groups and searched all over the place and haven't been able...
10
by: jojobar | last post by:
Hello, I am trying to use vs.net 2005 to migrate a project originally in vs.net 2003. I started with creation of a "web site", and then created folders for each component of the site. I read...
34
by: Jeff | last post by:
For years I have been using VBA extensively for updating data to tables after processing. By this I mean if I had to do some intensive processing that resulted in data in temp tables, I would have...
4
by: Steve | last post by:
When I create a new project in 2005, and I go to save the project files, vb.net displays a dialog box that repeats the name of the application and has a checkbox if I want to create a new directory...
7
by: Ashutosh Bhawasinka | last post by:
Hi, I have a C# .Net application which needs to use some feature which can be only developed in Visual C++ (its extended MAPI). The C# exe will be supplied to users without a setup. What kind...
10
by: Tammy | last post by:
Hello all, I am wondering what is the best way to declare a struct to be used in other c and c++ files. Such as for a C API that will be used by others. 1. Declaring the typedef and the...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
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,...
0
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...

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.