チェンジセット 1638 (default)
- 日時:
- 2024/02/13 2:41:40 (8ヵ月前)
- ファイル:
-
- 1個の更新
凡例:
- 未変更
- 追加
- 削除
-
framework/trunk/CoreLibrary/Sources/IO/IOUtility.cs
r1575 r1638 1125 1125 1126 1126 /// <summary> 1127 /// ストリームの現在のポジションから末尾まで読み込みバイト配列で返します。 1128 /// </summary> 1129 /// <param name="stream">読み込むストリーム。</param> 1130 /// <returns> 1131 /// 読み込んだバイト配列。 1132 /// </returns> 1133 /// <exception cref="ArgumentNullException"> 1134 /// <paramref name="stream"/> が <see langword="null"/> です。 1135 /// </exception> 1136 /// <exception cref="IOException"> 1137 /// I/O エラーが発生しました。 1138 /// </exception> 1139 public static byte[] ReadAll(Stream stream) 1140 { 1141 // 引数をチェック 1142 if (stream == null) 1143 { 1144 throw new ArgumentNullException("stream"); 1145 } 1146 1147 const int BufferSize = 0x2000; 1148 1149 using (MemoryStream memoryStream = new MemoryStream()) 1150 { 1151 int readLength; 1152 byte[] buffer = new byte[BufferSize]; 1153 while ((readLength = stream.Read(buffer, 0, BufferSize)) > 0) 1154 { 1155 memoryStream.Write(buffer, 0, readLength); 1156 } 1157 1158 return memoryStream.ToArray(); 1159 } 1160 } 1161 1162 /// <summary> 1127 1163 /// ストリームの内容を全て別のストリームにコピーします。 1128 1164 /// </summary>
※ 詳しい使い方は
TracChangeset を参照してください。