Solved

How do I create a temporary directory and later delete it?

Posted on 2008-10-23
3
851 Views
Last Modified: 2012-06-22
I have a zip file which I need to unzip into a directory and work on those files.

I need assistance in creating a temporary directory under the current working directory which will be deleted after the operation and this should be portable on windows and linux.
0
Comment
Question by:Cool-Guy
3 Comments
 
LVL 6

Accepted Solution

by:
Werrock earned 500 total points
ID: 22794037
Its a platform-dependent call so I would recommend you to check out the boost libraries at
http://www.boost.org/

More precisly, the filesystem library:
http://www.boost.org/doc/libs/1_36_0/libs/filesystem/doc/index.htm
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 22794252
standard C++ does not know how to create temporary directories. It can create temporary files though using tmpfile :

        http://www.cplusplus.com/reference/clibrary/cstdio/tmpfile.html

But that doesn't help you :)

There is a nice alternative : to use the system's temporary directory, which on POSIX compliant systems can be retrieved using the TMPDIR environment variable.
0
 

Author Closing Comment

by:Cool-Guy
ID: 31509540
Thanks for your time.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now