Export (0) Print
Expand All

TempFileCollection Class

Represents a collection of temporary files.

System.Object
  System.CodeDom.Compiler.TempFileCollection

Namespace:  System.CodeDom.Compiler
Assembly:  System (in System.dll)

[<SerializableAttribute>]
[<PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")>]
[<PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")>]
type TempFileCollection =  
    class 
        interface ICollection 
        interface IEnumerable 
        interface IDisposable 
    end

The TempFileCollection type exposes the following members.

  NameDescription
Public methodTempFileCollection()Initializes a new instance of the TempFileCollection class with default values.
Public methodTempFileCollection(String)Initializes a new instance of the TempFileCollection class using the specified temporary directory that is set to delete the temporary files after their generation and use, by default.
Public methodTempFileCollection(String, Boolean)Initializes a new instance of the TempFileCollection class using the specified temporary directory and specified value indicating whether to keep or delete the temporary files after their generation and use, by default.
Top

  NameDescription
Public propertyBasePathGets the full path to the base file name, without a file name extension, on the temporary directory path, that is used to generate temporary file names for the collection.
Public propertyCountGets the number of files in the collection.
Public propertyKeepFilesGets or sets a value indicating whether to keep the files, by default, when the Delete method is called or the collection is disposed.
Public propertyTempDirGets the temporary directory to store the temporary files in.
Top

  NameDescription
Public methodAddExtension(String)Adds a file name with the specified file name extension to the collection.
Public methodAddExtension(String, Boolean)Adds a file name with the specified file name extension to the collection, using the specified value indicating whether the file should be deleted or retained.
Public methodAddFileAdds the specified file to the collection, using the specified value indicating whether to keep the file after the collection is disposed or when the Delete method is called.
Public methodCopyToCopies the members of the collection to the specified string, beginning at the specified index.
Public methodDeleteDeletes the temporary files within this collection that were not marked to be kept.
Protected methodDisposeReleases the unmanaged resources used by the TempFileCollection and optionally releases the managed resources.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAttempts to delete the temporary files before this object is reclaimed by garbage collection. (Overrides Object.Finalize().)
Public methodGetEnumeratorGets an enumerator that can enumerate the members of the collection.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public Extension MethodAsParallel()Overloaded. Enables parallelization of a query. (Defined by ParallelEnumerable.)
Public Extension MethodAsParallel()Overloaded. (Defined by ParallelEnumerable.)
Public Extension MethodAsQueryable()Overloaded. Converts an IEnumerable to an IQueryable. (Defined by Queryable.)
Public Extension MethodAsQueryable()Overloaded. (Defined by Queryable.)
Public Extension MethodCast(TResult)()Overloaded. Casts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)
Public Extension MethodCast(TResult)()Overloaded. (Defined by Enumerable.)
Public Extension MethodOfType(TResult)()Overloaded. Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)
Public Extension MethodOfType(TResult)()Overloaded. (Defined by Enumerable.)
Top

  NameDescription
Explicit interface implemetationPrivate methodICollection.CopyToInfrastructure. Copies the elements of the collection to an array, starting at the specified index of the target array.
Explicit interface implemetationPrivate propertyICollection.CountInfrastructure. Gets the number of elements contained in the collection.
Explicit interface implemetationPrivate propertyICollection.IsSynchronizedInfrastructure. Gets a value indicating whether access to the collection is synchronized (thread safe).
Explicit interface implemetationPrivate propertyICollection.SyncRootInfrastructure. Gets an object that can be used to synchronize access to the collection.
Explicit interface implemetationPrivate methodIDisposable.DisposeInfrastructure. Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Explicit interface implemetationPrivate methodIEnumerable.GetEnumeratorInfrastructure. Returns an enumerator that iterates through a collection.
Top

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.

NoteNote

This class contains a link demand and an inheritance demand at the class level that applies to all members. A SecurityException is thrown when either the immediate caller or the derived class does not have full-trust permission. For details about security demands, see Link Demands and Inheritance Demands.

The following example shows the use of the TempFileCollection class and the AddExtension and AddFile methods.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

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