CSharpTest.Net
Delete() Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class > Delete Method : Delete() Method

Glossary Item Box

Deletes the current temp file immediatly if it exists.

Syntax

Visual Basic (Declaration) 
Public Overloads Sub Delete() 
C# 
public void Delete()

Example

Library/Library.Test/TestTempFiles.cs

C#Copy Code
string test = "Hello World!\u1255";
TempFile file = new TempFile();
File.WriteAllBytes(file.TempPath, Encoding.UTF8.GetBytes(test));

Assert.AreEqual(Encoding.UTF8.GetBytes(test), file.ReadAllBytes());
Assert.AreEqual(test, file.ReadAllText());

file.Delete();
Assert.IsFalse(File.Exists(file.TempPath));
Assert.IsFalse(file.Exists);
file.WriteAllBytes(Encoding.UTF8.GetBytes(test));
Assert.AreEqual(test, file.ReadAllText());

file.Delete();
Assert.IsFalse(File.Exists(file.TempPath));
Assert.IsFalse(file.Exists);
file.WriteAllText(test);
Assert.AreEqual(test, file.ReadAllText());
VB.NETCopy Code
Dim test As String = "Hello World!ቕ"
Dim file As New TempFile()
File.WriteAllBytes(file.TempPath, Encoding.UTF8.GetBytes(test))

Assert.AreEqual(Encoding.UTF8.GetBytes(test), file.ReadAllBytes())
Assert.AreEqual(test, file.ReadAllText())

file.Delete()
Assert.IsFalse(File.Exists(file.TempPath))
Assert.IsFalse(file.Exists)
file.WriteAllBytes(Encoding.UTF8.GetBytes(test))
Assert.AreEqual(test, file.ReadAllText())

file.Delete()
Assert.IsFalse(File.Exists(file.TempPath))
Assert.IsFalse(file.Exists)
file.WriteAllText(test)
Assert.AreEqual(test, file.ReadAllText())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members
Overload List

Used By

BasicFileTests.TestDeleteUnderlyingFile()
BasicFileTests.TestDeleteAfterGarbageCollection()
TestBulkInsert.TestMergeSequenceInFile()
TestBulkInsert.TestMergeRandomInFile()
TestTransactionLog.TestTransactionLogOptions()
ThreadedBTreeTest.TestAbortWritersAndRecover()

Source Code

Library/IO/TempFile.cs

Generated with Document! X 2011 by Innovasys