See Also: TempFileCollection Members
System.CodeDom.Compiler.TempFileCollection can be used to generate unique file names and to keep track of a list of files. This can be useful to System.CodeDom.Compiler.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 TempFileCollection.AddFile(string, bool) or TempFileCollection.AddExtension(string) methods, be deleted when the collection is disposed or the TempFileCollection.Delete method is called.
A file in any directory can be added to an instance of System.CodeDom.Compiler.TempFileCollection using the TempFileCollection.AddFile(string, bool) method.
To generate a unique name for a temporary file of a particular file extension, call TempFileCollection.AddExtension(string) and specifiy the extension of the file name to generate. The TempFileCollection.AddExtension(string) method will return a string consisting of a full path to a file name of the specified extension in the directory specified by the TempFileCollection.TempDir property. The TempFileCollection.AddExtension(string) method will only return one unique file name per file name extension.
Both the TempFileCollection.AddFile(string, bool) and TempFileCollection.AddExtension(string) methods have overloads that allow you to specify whether the files should be deleted when the collection is disposed or the TempFileCollection.Delete method is called.
The TempFileCollection.Delete method will delete all the files in the collection except those that are marked to be kept.
The TempFileCollection.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 TempFileCollection.AddExtension(string) method.
This class contains a link demand and an inheritance demand at the class level that applies to all members. A System.Security.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.