12 [PermissionSet(
SecurityAction.InheritanceDemand, Name =
"FullTrust")]
15 private string basePath;
17 private string tempDir;
19 private bool keepFiles;
79 EnsureTempNameCreated();
101 : this(null, keepFiles: false)
108 : this(tempDir, keepFiles: false)
118 this.keepFiles = keepFiles;
119 this.tempDir = tempDir;
126 Dispose(disposing:
true);
133 protected virtual void Dispose(
bool disposing)
141 Dispose(disposing:
false);
161 if (fileExtension ==
null || fileExtension.Length == 0)
163 throw new ArgumentException(SR.GetString(
"InvalidNullEmptyArgument",
"fileExtension"),
"fileExtension");
165 string text =
BasePath +
"." + fileExtension;
177 public void AddFile(
string fileName,
bool keepFile)
179 if (fileName ==
null || fileName.Length == 0)
181 throw new ArgumentException(SR.GetString(
"InvalidNullEmptyArgument",
"fileName"),
"fileName");
183 if (files[fileName] !=
null)
185 throw new ArgumentException(SR.GetString(
"DuplicateFileName", fileName),
"fileName");
187 files.
Add(fileName, keepFile);
215 public void CopyTo(
string[] fileNames,
int start)
220 private void EnsureTempNameCreated()
222 if (basePath ==
null)
231 basePath = GetTempFileName(
TempDir);
234 text = basePath +
".tmp";
244 uint num2 = 2147942480u;
253 files.
Add(text, keepFiles);
257 private bool KeepFile(
string fileName)
259 object obj = files[fileName];
270 if (files ==
null || files.
Count <= 0)
274 string[] array =
new string[files.
Count];
276 string[] array2 = array;
277 foreach (
string text
in array2)
287 internal void SafeDelete()
296 Executor.ReImpersonate(impersonation);
300 private void Delete(
string fileName)
311 private static string GetTempFileName(
string tempDir)
313 if (
string.IsNullOrEmpty(tempDir))
320 return tempDir + fileNameWithoutExtension;
322 return tempDir +
"\\" + fileNameWithoutExtension;
object SyncRoot
Gets an object that can be used to synchronize access to the T:System.Collections....
Provides command execution functions for invoking compilers. This class cannot be inherited.
FileIOPermissionAccess
Specifies the type of file access requested.
virtual void Add(object key, object value)
Adds an element with the specified key and value into the T:System.Collections.Hashtable.
static int GetHRForException(Exception e)
Converts the specified exception to an HRESULT.
static void SuppressFinalize(object obj)
Requests that the common language runtime not call the finalizer for the specified object.
StringComparison
Specifies the culture, case, and sort rules to be used by certain overloads of the M:System....
string AddExtension(string fileExtension, bool keepFile)
Adds a file name with the specified file name extension to the collection, using the specified value ...
FileMode
Specifies how the operating system should open a file.
Provides a mechanism for releasing unmanaged resources.To browse the .NET Framework source code for t...
TempFileCollection()
Initializes a new instance of the T:System.CodeDom.Compiler.TempFileCollection class with default val...
TempFileCollection(string tempDir)
Initializes a new instance of the T:System.CodeDom.Compiler.TempFileCollection class using the specif...
TempFileCollection(string tempDir, bool keepFiles)
Initializes a new instance of the T:System.CodeDom.Compiler.TempFileCollection class using the specif...
Exposes an enumerator, which supports a simple iteration over a non-generic collection....
SecurityAction
Specifies the security actions that can be performed using declarative security.
int Count
Gets the number of files in the collection.
bool KeepFiles
Gets or sets a value indicating whether to keep the files, by default, when the M:System....
Represents a collection of key/value pairs that are organized based on the hash code of the key....
virtual ICollection Keys
Gets an T:System.Collections.ICollection containing the keys in the T:System.Collections....
Provides a T:System.IO.Stream for a file, supporting both synchronous and asynchronous read and write...
The exception that is thrown when an I/O error occurs.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
bool IsSynchronized
Gets a value indicating whether access to the T:System.Collections.ICollection is synchronized (threa...
void CopyTo(string[] fileNames, int start)
Copies the members of the collection to the specified string, beginning at the specified index.
Provides a collection of methods for allocating unmanaged memory, copying unmanaged memory blocks,...
static string GetFullPath(string path)
Returns the absolute path for the specified path string.
IEnumerator GetEnumerator()
Returns an enumerator that iterates through a collection.
Controls the system garbage collector, a service that automatically reclaims unused memory.
The exception that is thrown when one of the arguments provided to a method is not valid.
void Demand()
Forces a T:System.Security.SecurityException at run time if all callers higher in the call stack have...
virtual void Dispose(bool disposing)
Releases the unmanaged resources used by the T:System.CodeDom.Compiler.TempFileCollection and optiona...
string TempDir
Gets the temporary directory to store the temporary files in.
FileAccess
Defines constants for read, write, or read/write access to a file.
virtual void Remove(object key)
Removes the element with the specified key from the T:System.Collections.Hashtable.
string BasePath
Gets the full path to the base file name, without a file name extension, on the temporary directory p...
static string GetTempPath()
Returns the path of the current user's temporary folder.
Specifies that the class can be serialized.
IEnumerator GetEnumerator()
Gets an enumerator that can enumerate the members of the collection.
void AddFile(string fileName, bool keepFile)
Adds the specified file to the collection, using the specified value indicating whether to keep the f...
static StringComparer OrdinalIgnoreCase
Gets a T:System.StringComparer object that performs a case-insensitive ordinal string comparison.
Provides static methods for the creation, copying, deletion, moving, and opening of a single file,...
static void Delete(string path)
Deletes the specified file.
int Count
Gets the number of elements contained in the T:System.Collections.ICollection.
Controls the ability to access files and folders. This class cannot be inherited.
static string GetRandomFileName()
Returns a random folder name or file name.
Defines size, enumerators, and synchronization methods for all nongeneric collections.
void CopyTo(Array array, int index)
Copies the elements of the T:System.Collections.ICollection to an T:System.Array, starting at a parti...
void Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resourc...
Supports a simple iteration over a non-generic collection.
Represents a collection of temporary files.
Performs operations on T:System.String instances that contain file or directory path information....
string AddExtension(string fileExtension)
Adds a file name with the specified file name extension to the collection.
void Delete()
Deletes the temporary files within this collection that were not marked to be kept.
virtual int Count
Gets the number of key/value pairs contained in the T:System.Collections.Hashtable.
static string GetFileNameWithoutExtension(string path)
Returns the file name of the specified path string without the extension.
Represents a string comparison operation that uses specific case and culture-based or ordinal compari...
Represents the Windows user prior to an impersonation operation.