System.CodeDom.Compiler.TempFileCollection Class

Assembly: System.dll
Namespace: System.CodeDom.Compiler
Summary
Represents a collection of temporary files.
C# Syntax:
public class TempFileCollection : ICollection, IEnumerable, IDisposable
Remarks
TempFileCollection provides an object that can represent a collection of temporary files and values indicating whether each should be deleted when the collection is either closed or the TempFileCollection.Delete method is called. Being able to generate and dispose of temporary files is of particular use to ICodeCompiler implementations.

The TempFileCollection.AddFile method adds the specified file name to the collection and indicates whether the file should be marked for later deletion.

The TempFileCollection.AddExtension method returns a filename for the specified type of extension and adds the filename to the collection. This method can be called only once per file type, as it will return the same file name for the same extension.

The TempFileCollection.Delete method will delete all the files that have been marked for deletion when the collection object is disposed or the TempFileCollection.Delete method is called.

See also:
System.CodeDom.Compiler Namespace

System.CodeDom.Compiler.TempFileCollection Member List:

Public Constructors
ctor #1 Overloaded:
.ctor()

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
Initializes a new instance of the TempFileCollection class with default values.
ctor #2 Overloaded:
.ctor(string tempDir)

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.
ctor #3 Overloaded:
.ctor(string tempDir, bool keepFiles)

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.
Public Properties
BasePath Read-only

Gets the base path to store the files in.
Count Read-only

Gets the count of files in the collection.
KeepFiles Read-write

Gets or sets a value indicating whether to keep the files after they are no longer needed by the current compilation.
TempDir Read-only

Gets the temporary directory to store the temporary files in.
Public Methods
AddExtension Overloaded:
AddExtension(string fileExtension)

Adds a file name with the specified file name extension to the collection.
AddExtension Overloaded:
AddExtension(string fileExtension, bool keepFile)

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.
AddFile Adds the specified file to the collection, using the specified value indicating whether to keep the file after the collection is disposed or when the TempFileCollection.Delete method is called.
CopyTo Copies the members of the collection to the specified string, beginning at the specified index.
Delete Deletes the temporary files within this collection that were not marked to be kept.
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetEnumerator Gets an enumeration of the members of the collection.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Methods
Dispose Releases the unmanaged resources used by the TempFileCollection and optionally releases the managed resources.
Finalize Overridden:
Finalizes the collection.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.CodeDom.Compiler.TempFileCollection Member Details

Overloaded ctor #1
Summary
Initializes a new instance of the TempFileCollection class with default values.

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
C# Syntax:
public TempFileCollection();
Remarks
This is a default constructor that initializes the collection with default settings. By default, this temporary files collection will store the files in a default temporary directory and will delete the temporary files after they have been generated and used.

Return to top


Overloaded ctor #2
Summary
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.
C# Syntax:
public TempFileCollection(
   string tempDir
);
Parameters:

tempDir

A temporary directory to use for storing the temporary files.

Return to top


Overloaded ctor #3
Summary
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.
C# Syntax:
public TempFileCollection(
   string tempDir,
   bool keepFiles
);
Parameters:

tempDir

A temporary directory to use for storing the temporary files.

keepFiles

true if the temporary files should be kept after use; false if the temporary files should be deleted.

Return to top


Property: BasePath (read-only)
Summary
Gets the base path to store the files in.
C# Syntax:
public string BasePath {get;}

Return to top


Property: Count (read-only)
Summary
Gets the count of files in the collection.
C# Syntax:
public int Count {get;}

Return to top


Property: KeepFiles (read-write)
Summary
Gets or sets a value indicating whether to keep the files after they are no longer needed by the current compilation.
C# Syntax:
public bool KeepFiles {get; set;}

Return to top


Property: TempDir (read-only)
Summary
Gets the temporary directory to store the temporary files in.
C# Syntax:
public string TempDir {get;}

Return to top


Overloaded Method: AddExtension(
   string fileExtension
)
Summary
Adds a file name with the specified file name extension to the collection.
C# Syntax:
public string AddExtension(
   string fileExtension
);
Parameters:

fileExtension

The file name extension to add.

Return Value:
A file name with the specified extension that was just added to the collection.
Remarks
This method returns a file name with the specified extension that has been added to the temporary files collection. Other code must still create the file before it can be used.

This method can be called only once for each file name extension since it will return the same name if called with the same extension.

Return to top


Overloaded Method: AddExtension(
   string fileExtension,
   bool keepFile
)
Summary
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.
C# Syntax:
public string AddExtension(
   string fileExtension,
   bool keepFile
);
Parameters:

fileExtension

The file name extension to add.

keepFile

true if the files of this type should be kept after use; false if the files of this type should be deleted.

Return Value:
A file name with the specified extension that was just added to the collection.
Remarks
This method returns a file name with the specified extension that has been added to the temporary files collection. Other code must still create the file before it can be used.

This method can be called only once for each file name extension since it will return the same name if called with the same extension.

Return to top


Method: AddFile(
   string fileName,
   bool keepFile
)
Summary
Adds the specified file to the collection, using the specified value indicating whether to keep the file after the collection is disposed or when the TempFileCollection.Delete method is called.
C# Syntax:
public void AddFile(
   string fileName,
   bool keepFile
);
Parameters:

fileName

The name of the file to add to the collection.

keepFile

true if the file should be kept after use; false if the file should be deleted.

Return to top


Method: CopyTo(
   string[] fileNames,
   int start
)
Summary
Copies the members of the collection to the specified string, beginning at the specified index.
C# Syntax:
public void CopyTo(
   string[] fileNames,
   int start
);
Parameters:

fileNames

The array of strings to copy to.

start

The index of the array to begin copying to.

Return to top


Method: Delete()
Summary
Deletes the temporary files within this collection that were not marked to be kept.
C# Syntax:
public void Delete();

Return to top


Method: Dispose(
   bool disposing
)
Summary
Releases the unmanaged resources used by the TempFileCollection and optionally releases the managed resources.
C# Syntax:
protected virtual void Dispose(
   bool disposing
);
Parameters:

disposing

true to release both managed and unmanaged resources; false to release only unmanaged resources.

Remarks
This method is called by the Dispose method and the Object.Finalize method.Dispose() invokes the protected Dispose(Boolean) method with the disposing parameter set to true. Object.Finalize invokes Dispose with disposing set to false.

When the disposing parameter is true, this method releases all resources held by any managed objects that this TempFileCollection references. This method invokes the Dispose() method of each referenced object.



Notes to inheritors: Dispose can be called multiple times by other objects. When overriding Dispose(Boolean), be careful not to reference objects that have been previously disposed of in an earlier call to Dispose. For more information about how to implement Dispose, see the conceptual topic at MSDN: implementingdisposemethod.

For more information about Dispose and Finalize, see the conceptual topic at MSDN: cleaningupunmanagedresources and the conceptual topic at MSDN: overridingfinalizemethod.

See also:
MSDN: implementingdisposemethod | MSDN: cleaningupunmanagedresources

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Overridden Method: Finalize()
Summary
Finalizes the collection.
C# Syntax:
~TempFileCollection();

Return to top


Method: GetEnumerator()
Summary
Gets an enumeration of the members of the collection.
C# Syntax:
public IEnumerator GetEnumerator();
Return Value:
An IEnumerator that contains the collection's members.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.