Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Temporary file
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Computer file type}} {{more citations needed|date=January 2021}} A '''temporary file''' is a file created to store information temporarily, either for a program's intermediate use or for transfer to a permanent file when complete.<ref>{{cite web |url=http://support.microsoft.com/kb/92635 |title=Windows Temporary Files |date=7 July 2005 |access-date=20 October 2019 |work=[[Microsoft]] Support |archive-url=https://web.archive.org/web/20100420195830/http://support.microsoft.com/kb/92635 |archive-date=20 April 2010}}</ref> It may be created by [[computer program]]s for a variety of purposes, such as when a program cannot allocate enough memory for its tasks, when the program is working on data bigger than the architecture's [[address space]], or as a primitive form of [[inter-process communication]]. == Auxiliary memory == Modern [[operating system]]s employ [[virtual memory]], however programs that use large amounts of data (e.g. [[Video editing software|video]]) may need to create temporary file(s). == Inter-process communication == Most operating systems offer primitives such as [[Pipeline (software)|pipes]], [[Internet socket|sockets]] or [[Shared memory (interprocess communication)|shared memory]] to pass data among programs, but often the simplest way (especially for programs that follow the [[Unix philosophy]]) is to write data into a temporary file and inform the receiving program of the location of the temporary file. == Creation == Operating systems and programming languages typically provide functions for obtaining unique temporary file names. On [[POSIX]] systems, temporary files can be safely created with the <code>[[mkstemp]]</code> or {{man|sh|tmpfile|SUS||inline}} library functions. Some systems provide the former [[POSIX]] (now removed) {{man|1|mktemp|die.net||inline}} program. These files are typically located in the standard temporary directory, <kbd>/tmp</kbd> on Unix machines or <kbd>%TEMP%</kbd> (which is log-in specific) on Windows machines. A temporary file created with {{man|sh|tmpfile|SUS||inline}} is deleted automatically when the program exits or the file is closed. To generate a temporary file name that will survive past the lifespan of the creating program, {{man|sh|tmpnam|SUS||inline}} (POSIX) or <code>GetTempFileName(...)</code> (Windows) can be used. [[PHP]] have the {{Code|tmpfile}} function.<ref>{{cite web |title=PHP: tmpfile - Manual |url=https://www.php.net/manual/en/function.tmpfile.php |website=www.php.net |access-date=6 May 2025 |language=en}}</ref> [[Python (programming language)|Python]] have the {{Code|tempfile}} module.<ref>{{cite web |title=tempfile β Generate temporary files and directories |url=https://docs.python.org/3/library/tempfile.html |website=Python documentation |access-date=6 May 2025 |language=en}}</ref> [[Rust (programming language)|Rust]] have the third-party crate tempfile.<ref>{{cite web |title=crates.io: Rust Package Registry |url=https://crates.io/crates/tempfile |website=crates.io |access-date=6 May 2025 |language=en}}</ref> [[.NET]] have the {{Code|Path.GetTempFileName}} method.<ref>{{cite web |title=Path.GetTempFileName Method (System.IO) |url=https://learn.microsoft.com/en-us/dotnet/api/system.io.path.gettempfilename?view=net-9.0 |website=learn.microsoft.com |access-date=6 May 2025 |language=en-us}}</ref> == Issues == Some programs create temporary files and then leave them behind - they do not delete them. This can happen because the program [[crash (computing)|crashed]] or the developer of the program simply forgot to add the code needed to delete the temporary files after the program is done with them. The temporary files left behind can accumulate over time and consume a lot of disk space. Temporary files may be deleted manually. Operating systems may clear out the temporary directory on a reboot, and they may have "cleaner" scripts that remove files if they have not been accessed in a certain amount of time. Also, memory-based filesystems, such as [[tmpfs]], inherently do not preserve files across a reboot. ==See also== *[[Temp File Cleaner]] *[[Temporary folder]] *[[Temporary filesystem]] *[[Temporary variable]] ==References== {{reflist}} {{Computer files}} [[Category:Computer file systems]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Cite web
(
edit
)
Template:Code
(
edit
)
Template:Computer files
(
edit
)
Template:Man
(
edit
)
Template:More citations needed
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)