BinaryReader.ReadChars メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Dim instance As BinaryReader Dim count As Integer Dim returnValue As Char() returnValue = instance.ReadChars(count)
戻り値
基になるストリームから読み取ったデータが格納されている文字配列。ストリームの末尾に到達した場合は、要求された文字数より小さくなることがあります。


BinaryReader は、読み取りが失敗した後にファイルを元に位置に戻しません。
その他の一般的な I/O タスクまたは関連する I/O タスクの例を次の表に示します。
File.AppendText FileInfo.AppendText | |
FileInfo.Length | |
File.GetAttributes | |
File.SetAttributes | |

メモリをバッキング ストアとして使用してデータを読み書きする方法の例を次に示します。
Imports System Imports System.IO Public Class BinaryRW Shared Sub Main() Dim invalidPathChars() As Char = Path.InvalidPathChars Dim memStream As new MemoryStream() Dim binWriter As New BinaryWriter(memStream) ' Write to memory. binWriter.Write("Invalid file path characters are: ") binWriter.Write(Path.InvalidPathChars) ' Create the reader using the same MemoryStream ' as used with the writer. Dim binReader As New BinaryReader(memStream) ' Set Position to the beginning of the stream. memStream.Position = 0 ' Read the data from memory and write it to the console. Console.Write(binReader.ReadString()) Console.WriteLine(binReader.ReadChars( _ CInt(memStream.Length - memStream.Position))) End Sub End Class
using System; using System.IO; class BinaryRW { static void Main() { char[] invalidPathChars = Path.InvalidPathChars; MemoryStream memStream = new MemoryStream(); BinaryWriter binWriter = new BinaryWriter(memStream); // Write to memory. binWriter.Write("Invalid file path characters are: "); binWriter.Write(Path.InvalidPathChars); // Create the reader using the same MemoryStream // as used with the writer. BinaryReader binReader = new BinaryReader(memStream); // Set Position to the beginning of the stream. memStream.Position = 0; // Read the data from memory and write it to the console. Console.Write(binReader.ReadString()); Console.WriteLine(binReader.ReadChars( (int)(memStream.Length - memStream.Position))); } }
using namespace System; using namespace System::IO; int main() { array<Char>^invalidPathChars = Path::InvalidPathChars; MemoryStream^ memStream = gcnew MemoryStream; BinaryWriter^ binWriter = gcnew BinaryWriter( memStream ); // Write to memory. binWriter->Write( "Invalid file path characters are: " ); binWriter->Write( Path::InvalidPathChars ); // Create the reader using the same MemoryStream // as used with the writer. BinaryReader^ binReader = gcnew BinaryReader( memStream ); // Set Position to the beginning of the stream. binReader->BaseStream->Position = 0; // Read the data from memory and write it to the console. Console::Write( binReader->ReadString() ); Console::WriteLine( binReader->ReadChars( (int)(memStream->Length - memStream->Position) ) ); }
import System.*; import System.IO.*; class BinaryRW { public static void main(String[] args) { char invalidPathChars[] = Path.InvalidPathChars; MemoryStream memStream = new MemoryStream(); BinaryWriter binWriter = new BinaryWriter(memStream); // Write to memory. binWriter.Write("Invalid file path characters are: "); binWriter.Write(Path.InvalidPathChars); // Create the reader using the same MemoryStream // as used with the writer. BinaryReader binReader = new BinaryReader(memStream); // Set Position to the beginning of the stream. memStream.set_Position(0); // Read the data from memory and write it to the console. Console.Write(binReader.ReadString()); Console.WriteLine(binReader.ReadChars((int) (memStream.get_Length() - memStream.get_Position()))); } //main } //BinaryRW

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からBinaryReader.ReadChars メソッドを検索する場合は、下記のリンクをクリックしてください。

- BinaryReader.ReadChars メソッドのページへのリンク