- Notifications
You must be signed in to change notification settings - Fork 0
Igor edited this page Mar 2, 2015
·
11 revisions
Project Description The project presents .NET 4.0 library NFile (different file/folder implementations).
The project presents .NET 4.0 library NFile. The library implements several types of "File" and "Folder" classes:
- TemporaryFile implements temporary file. The file always will be deleted (in Dispose() or in ~TemporaryFile() finalizer methods).
- TemporaryFolder implements temporary folder. The folder always will be deleted (in Dispose() or in ~TemporaryFolder() finalizer methods).
To install NFile, run the following command in the Package Manager Console
TemporaryFile Samples
using(TemporaryFiletemporaryFile=newTemporaryFile()){File.WriteAllText(temporaryFile.FileName,"[0]: test");File.AppendAllText(temporaryFile.FileName,"[1]: additional text");stringallText=File.ReadAllText(temporaryFile.FileName);Assert.AreEqual("[0]: test"+"[1]: additional text",allText);}TemporaryFolder Samples
using(TemporaryFoldertemporaryFolder=newTemporaryFolder()){stringfilePath=Path.Combine(temporaryFolder.Folder,"file1.txt");File.WriteAllText(filePath,"[0]: test");File.AppendAllText(filePath,"[1]: additional text");stringallText=File.ReadAllText(filePath);Assert.AreEqual("[0]: test"+"[1]: additional text",allText);}TemporaryCollection Samples
stringfileName;`
stringfolderName;`
using(vartemporaryCollection=newTemporaryCollection()){ITemporaryFilefile=temporaryCollection.AddFile();ITemporaryFolderfolder=temporaryCollection.AddFolder();fileName=file.FileName;folderName=folder.Folder;Assert.IsTrue(File.Exists(fileName));Assert.IsTrue(Directory.Exists(folderName));}Assert.IsFalse(File.Exists(fileName));Assert.IsFalse(Directory.Exists(folderName));