Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

TempFileCollection Class

Represents a collection of temporary files.

For a list of all members of this type, see TempFileCollection Members.

System.Object
   System.CodeDom.Compiler.TempFileCollection

[Visual Basic]
Public Class TempFileCollection
   Implements ICollection, IEnumerable, IDisposable
[C#]
public class TempFileCollection : ICollection, IEnumerable,
   IDisposable
[C++]
public __gc class TempFileCollection : public ICollection,
   IEnumerable, IDisposable
[JScript]
public class TempFileCollection implements ICollection,
   IEnumerable, IDisposable

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Remarks

TempFileCollection can be used to generate unique file names and to keep track of a list of files. This can be useful to ICodeCompiler implementers when managing a list of compiler-generated intermediate files, which are sometimes deleted after use.

To specify a directory to generate unique temporary file names in, use an appropriately overloaded constructor. You can also use a constructor overload to indicate whether files added to the collection should, if not specified otherwise when using the AddFile or AddExtension methods, be deleted when the collection is disposed or the Delete method is called.

A file in any directory can be added to an instance of TempFileCollection using the AddFile method.

To generate a unique name for a temporary file of a particular file extension, call AddExtension and specifiy the extension of the file name to generate. The AddExtension method will return a string consisting of a full path to a file name of the specified extension in the directory specified by the TempDir property. The AddExtension method will only return one unique file name per file name extension.

Both the AddFile and AddExtension methods have overloads that allow you to specify whether the files should be deleted when the collection is disposed or the Delete method is called.

The Delete method will delete all the files in the collection except those that are marked to be kept.

The BasePath property indicates a full path to the base file name, without a file name extension, used to generate the file names returned by the AddExtension method.

Requirements

Namespace: System.CodeDom.Compiler

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System (in System.dll)

See Also

TempFileCollection Members | System.CodeDom.Compiler Namespace

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.