The information in this article applies to:
SUMMARYThis article explains when, where, and how Microsoft Word for Windows creates temporary files. MORE INFORMATIONDefinition of a Temporary FileA program creates a temporary file to temporarily store information. The program determines where and when to create temporary files. Temporary files are available only for the current session of the program.Why Does Word Create Temporary Files?Speed:Word sometimes copies portions of a file into memory so that it can access the information more quickly when you copy and paste or scroll through a document. Word references the location of the information instead of actually accessing the information, which reduces the time Word spends performing these functions. Data Integrity: Word's uses temporary files as a "safety net" to protect against system errors in its file saving scheme. By saving to a temporary file first and then renaming the file to the proper name, Word ensures the data integrity of your original file against problems (such as a power failure or lost network connections) that might occur while the file is being written. Temporary Files In Word 6.x, 7.xWord creates a variety of temporary files.MS-DOS-Based File: These are standard MS-DOS files. Document File Based File: The difference between this file and a traditional MS-DOS file is that multiple programs can read and write to these files without the original owner knowing about it. Additionally, document files have inherent properties that allow Word to create files and directories within files. At startup, Word creates one temporary (direct) document file Called ~wrfxxxx.tmp. You can determine that it is a document file because the initial size is 1536 bytes. This temporary document file is used to store all OLE objects belonging to unnamed documents, undo, the Clipboard, and to documents whose native formats are not document format (for example, .txt, .rtf, and Word 2.0 documents). Word can open document files using two different modes: transacted and direct. These modes are discussed later in this article. Transacted Document Files: Transacted files allow Word to open a file, write to it, and have other programs--such as Microsoft Excel--write to it, but still retain the right to restore the file to the state it was in when Word first opened it. To do this, the document file creates ghost images (typically ~dftxxxx.tmp) of all the changes made to the file after it was opened; if Word keeps all the changes, the contents of ~dftxxxx.tmp merge with the original file, and then saves a complete version of it. On the other hand, if Word discards all changes, then ~dftxxxx.tmp is deleted, and the original file does not change. Word opens all of the Word 6.0 native files using transacted files, which create ghost images in the Temp directory. When you start Word, Normal.dot is typically opened in transacted mode, and a ghost file is created for it called dftxxxx.tmp. FastSave, for example, merges these two files when a save occurs. Direct: Word uses direct storage when opening the temporary document file and when performing either a Save As or a Full Save (non-FastSave save). This type of file is a low (if any) consumer of memory and does not create a ghost image when created or opened. Specific Files That Word Versions 6.x, 7.x CreateThe following tables list some of the specific temporary files that Word creates.
A Simplified View of the Scheme Used to Save an Edited File
Word gains significant performance speed by placing the temporary file in the same directory as the saved file. If Word placed the temporary file elsewhere, it would have to use the MS-DOS COPY command to move the temporary file from the other directory to the saved location. By leaving the temporary file in the same directory as the saved document file, Word can use the MS-DOS MOVE command to quickly designate the temporary file as the saved document. When and Where Word Creates Temporary FilesThe location of where Word creates the temporary files is hardcoded information and cannot be edited. In general, Word creates temporary files for the following types of data.Embedded Word Objects (Temp Directory): When Word acts as an OLE server program, the embedded Word objects are stored as temporary files in the Temp directory. OLE 2.0 requires extra drive storage. When you start OLE programs, Word needs to provide copies of the data to the server. It is not Unusual for extensive OLE 2.0 usage in a single session of a program to accumulate a large amount of temporary storage on the hard drive. Scratch File (Temp Directory): When Word runs out of internal random access memory (RAM), it always creates a single temporary scratch file in the Temp directory to hold information. This scratch file holds information that is swapped out from the Word internal file cache, which is allocated from global system memory. The scratch file varies in size from 64 kilobytes (KB) to 3.5 megabytes (MB). You can prevent Word from having to write to the scratch file by allocating more RAM for Word to use internally. The default cachesize in Word is 64 KB. For more information about increasing the cachesize in Word, please see the following articles in the Microsoft Knowledge Base: Recorded Macro (Temp Directory):Q108503 WD1015: How to Optimize the Performance of Word 6.0Q135872 WD95: Where Settings Are Stored in the Registry When you record a macro, Word creates a temporary file in the Temp directory. Converted Files (Temp Directory): The word processor converters supplied with Word create temporary files in Rich Text Format (RTF), which Word uses to access specific converters. Locked Files (Temp Directory): When you open a file that is locked, either because it is open in another window of Word or because another user on the network has it open, you can work with a copy of the file. Word places this copy in the Windows Temp directory. Likewise, if a template attached to a document is locked, Word automatically makes a copy of the template in the Temp directory. The copy of a locked file does not automatically update the original owner's file. Saved Files (Same Directory as the Saved File): When you click Save on the File menu, the following happens: - Word builds a new temporary file using the edited version of the document. - Once Word successfully creates the temporary file, Word deletes the previous version of the document. - Word renames the temporary file to the same name as the previous version of the document.Text Pasted Between Files (Same Directory as Source File): When Word copies and pastes between documents, it may create a temporary file in the same directory as the source file--especially if the source file is saved or closed. The temporary file represents the information that was referenced by the Clipboard prior to saving the file. Word creates this temporary file by renaming the old copy of the file to a temporary file name. Owner File (Same Directory as Source File): When a previously saved file is opened for editing, printing or review, Word creates a temporary file with a .doc file name extension that begins with a tilde "~" followed by a dollar sign "$" followed by the remainder of the original file name. This temporary file holds the logon name of person opening the file and is known as the "owner file." When you attempt to open a file that is available on a network and is already open by someone else, this file supplies the <user name> for the following error message: "This file is already opened by <user name>. Would you like to make a copy of this file for your use?"If the Owner File is damaged or missing the error message changes to: "This file is already opened by another user. Would you like to make a copy of this file for your use?"Word automatically deletes this temporary file when the original file is closed from memory. Automatic Save: Word 6.x/7.x Automatic Save Directory: The temporary file created when Word performs an automatic save is stored in the Autosave directory. The default Autosave directory is the Temp directory. Under Windows 95, Word 6.x will create a temporary file with a file name extension of .doc in the same directory where Word opens a document. For example, when opening Test.doc the result is a temporary file called ~$Test.doc. If Word quits abnormally, for example if Word stops responding, these files remain in that directory. The Location of Temporary Files When You Close a FileWord may occasionally have to maintain a link to a file after it is closed. This occurs when text has been copied to the Clipboard from the file. When you close a file, Word attempts the following actions:
WORD VERSION 2.x AND EARLIERGeneral Notes: How Word for Windows Handles FilesAll Word version 2.x for Windows files are always stored on disk and referenced during each Word session. Word for Windows sometimes copies portions of a file into memory so that Word can access the information more quickly when you copy and paste information or scroll through a document.Word references the location of the information instead of actually accessing the information, which reduces the time Word spends performing these functions. If you copy large portions of a Word document to the Clipboard, Word for Windows maintains an open handle to the file that contains the copied information. In MS-DOS, you can use the RENAME command within a directory. If you want to move a file to another directory, you must use the COPY command. The COPY command is slower than the RENAME command because COPY rewrites the entire file to disk, whereas RENAME changes only a few bytes of the file. When and Where Word for Windows Creates Temporary FilesRecorded Macro (Temp Directory):When you record a macro, Word for Windows creates a temporary file in the Temp directory. This also occurs when it duplicates a template because the macros in the template are duplicated through the recording code. The Temp directory is specified using the SET TEMP command, which is usually located in your Autoexec.bat file. File Save (Same Directory as the Saved File): When you run the File Save command, Word does the following things: - Word builds a new temporary file (named ~doc####.tmp) using the edited version of the document.NOTE: If Always Create Backup is selected, Word renames the previous version with a .bak file name extension instead of deleting it. Word for Windows gains significant performance speed by placing the temporary file in the same directory as the saved file. If Word placed the temporary file elsewhere, it would have to use the MS-DOS COPY command to move the temporary file from the other directory to the saved location. By leaving the temporary file in the same directory as the saved document file, Word can use the MS-DOS RENAME command to quickly designate the temporary file as the saved document file. Word for Windows uses this scheme to protect against system errors. By saving to a temporary file first and then renaming the file to the proper name, Word ensures the integrity of your original file against problems (such as a power failure or lost network connections) that might occur while the file is being written. If Word for Windows wrote directly over the original file or copied the file from another directory, the original file would be more vulnerable to damage. Open a Locked File (Temp Directory): When you open a file that is locked, either because it is open in another instance of Word for Windows or because another user on the network has it open, you can make a copy of the file. Word for Windows places this copy in the Windows Temp directory. If you attach a locked template, Word for Windows automatically makes a copy of the file in the Temp directory. Note: This copy of a locked file does not automatically update the original owner's file. AutoSave (Autosave Directory): The temporary file created when Word for Windows performs an AutoSave is stored in the Autosave directory, which is defined in the [Microsoft Word 2.0] section of the Windows WIN.INI file. Embedded Word Objects (Temp Directory): When Word for Windows acts as an object-linking-and-embedding (OLE) server program, the embedded Word objects are stored as temporary files in the Temp directory. Scratch File (Temp Directory): When Word for Windows runs out of internal RAM, it always creates a single temporary scratch file in the Temp directory to hold information. This scratch file holds information that is swapped out from the Word for Windows internal file cache, which is allocated from global system memory. The scratch file varies in size from 64 KB to 3.5 MB. You can prevent Word from having to write to the scratch file by allocating more RAM for Word to use internally. You do so by increasing the CACHESIZE setting in the [Microsoft Word 2.0] section of the Win.ini file. Experimentation is required to find optimal settings for every configuration. Converting Files (Temp Directory): The word processing converters supplied with Word for Windows create temporary files in RTF file format, which are read when Word accesses a specific converter. Paste Between Files (Same Directory as Source File): When Word copies and pastes between documents, it may create a temporary file in the same directory as the source file, especially if the source file is saved or closed. The temporary file represents the information that was referenced by the Clipboard prior to saving the file. Word for Windows creates this temporary file by renaming the old copy of the file to a temporary file name (~doc####.tmp). Owner File (Same Directory as Source File): When a previously saved file is opened for editing, printing or review, Word creates a temporary file with a .doc file name extension that begins with a tilde "~" followed by a dollar sign "$" followed by the remainder of the original file name. This temporary file is a copy of the original file that is open and is referred to as the "owner file." When you attempt to open a file that is available on a network and is already open by someone else, this file causes Word to prompt the following error message: "This file is already opened by USER Name. Would you like to make a copy of this file for your use?"Word automatically deletes this temporary file when the original file is closed from memory. REFERENCESFor additional information, please see the following articles in the Microsoft Knowledge Base: See also the "Microsoft Word 6.0 for Windows Resource Kit."Q86271 Error Message: Unrecoverable Disk Error on File ~doc####.tmpQ105593 List of WINWORD6.INI Settings: Word Default Settings Additional query words: tmp temp
Keywords : kbdta wordnt winword ntword word6 winword2 word7 word95 |
Last Reviewed: July 30, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |