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.NET | Copy 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()) |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
Reference
TempFile ClassTempFile Members
Used By
TestResXtoMcByProject.TestCreateMessageAssembly()TempFile.Delete()