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

Glossary Item Box

Reads all bytes from the file

Syntax

Visual Basic (Declaration) 
Public Function ReadAllBytes() As Byte()
C# 
public byte[] ReadAllBytes()

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

Used By

TestTransactionLog.TestLogCorruption()

Source Code

Library/IO/TempFile.cs

Generated with Document! X 2011 by Innovasys