472,793 Members | 2,275 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

get temp directory

How to get user temporany directory from c++ function?

example:

string myTempDir = getTempDir();

now myTempDir contains 'c:\tmp'

is there a portable function?
Feb 28 '08 #1
3 5809
Alberto Bignotti wrote:
How to get user temporany directory from c++ function?

example:

string myTempDir = getTempDir();

now myTempDir contains 'c:\tmp'

is there a portable function?
No, there is no portable function because there is no portable
notion of "user temporary directory". However, you could try
'getenv("TEMP")' or 'getenv("TMP")'. RTFM about it.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Feb 28 '08 #2
On Feb 28, 4:00 pm, "Alberto Bignotti" <a.bigno...@abacogroup.com>
wrote:
How to get user temporany directory from c++ function?

example:

string myTempDir = getTempDir();

now myTempDir contains 'c:\tmp'

is there a portable function?
Alberto,

As Victor says c++ has no notion of a temporary file directory, but if
you just want to create a temporary file the the C library's stdio
header provides the function tmpfile():
http://www.cplusplus.com/reference/c...o/tmpfile.html

HTH,
--rob
Feb 28 '08 #3
On Feb 28, 5:03 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
Alberto Bignotti wrote:
How to get user temporany directory from c++ function?
example:
string myTempDir = getTempDir();
now myTempDir contains 'c:\tmp'
is there a portable function?
No, there is no portable function because there is no portable
notion of "user temporary directory". However, you could try
'getenv("TEMP")' or 'getenv("TMP")'. RTFM about it.
TMPDIR is what Posix recommends, I think.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Feb 28 '08 #4

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

Similar topics

3
by: Adam Parkin | last post by:
I was wondering, what's the "proper" (hehe) way to retrieve the system's temp directory in VB 6. Like for example, on my Windows XP machine the temp directory that is used by programs for their...
1
by: john bailo | last post by:
I noticed for the first time there is a temp directory in the \winnt\system32 directory. For a web services application, this caused me grief as when the server c: drive filled up, the temp...
0
by: Matthew Fitzpatrick | last post by:
My application has a settings class that is serialized to save and deserialized to load. I'm having a problem where i catch the WM_QUERYENDSESSION event via WinProc to save my application's...
5
by: Patrick | last post by:
Hello - I am working on a program that creates a small temp file. The ideal would be it creates the file in the user %temp% directory - whatever that is - the default is %USERPROFILE%\Local...
2
by: Lars Netzel | last post by:
I'm trying to write a PDF to disk on the server (crystal reports export) I'm getting aproblem that Access is denied to save the file to disk and reading here (you don't need to read):...
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...
0
by: Andrés G. Aragoneses | last post by:
When trying to use a webservices, not very often I obtain the following exception: Server was unable to process request. ---> Access to the temp directory is denied. Identity 'NT...
6
by: Najd | last post by:
Hi All, I'm developping a DLL that requiers the path of the Temp directory of the user logged. I used GetTempPath(), GetEnvironmentVariable() and ExpandEnvironmentStrings(), but the 3 methodes...
0
by: oritc123 | last post by:
Hello . I am having the following error when I run my application under Windows Vista ( it runs fine under Windows XP ) : "Access to the temp directory is denied. Identity 'ORITSLAPTOP\orit'...
6
by: Aussie Rules | last post by:
Hi, In my application I need to write an XML file to disk, but am concerned that permission might be a problem. The file only needs to be written out and used for another reason and can then...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.