473,386 Members | 1,841 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,386 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 5862
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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
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...

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.