本文整理汇总了C#中System.IO.Stream.Read方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.Stream.Read方法的具体用法?C# System.IO.Stream.Read怎么用?C# System.IO.Stream.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.Stream
的用法示例。
在下文中一共展示了System.IO.Stream.Read方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyStream
private static void CopyStream(Stream input, Stream output)
{
byte[] buffer = new byte[32768];
while (true)
{
int read = input.Read(buffer, 0, buffer.Length);
if (read <= 0)
return;
output.Write(buffer, 0, read);
}
}
示例2: Block
public Block (System.IO.Stream stream)
{
this.stream = stream;
Start = stream.Position;
name = new byte [4];
byte [] tmp = new byte [8];
stream.Read (tmp, 0, tmp.Length);
System.Array.Copy (tmp, name, name.Length);
//System.Console.WriteLine (this.Name);
Length = BitConverter.ToUInt32 (tmp, name.Length, false);
stream.Position = stream.Position + Length;
}
示例3: GMKIn
public GMKIn(System.IO.Stream source)
{
s = source;
int tpos = (int)s.Position;
len = (int)s.Length;
s.Seek(0, System.IO.SeekOrigin.Begin);
s.Read(buffer, 0, 16);
int junk1 = BitConverter.ToInt32(buffer, 8);
int junk2 = BitConverter.ToInt32(buffer, 12);
s.Seek(junk1 * 4, System.IO.SeekOrigin.Current);
s.Read(buffer, 8, 4);
int seed = BitConverter.ToInt32(buffer, 8);
table = GenerateSwapTable(seed);
s.Seek(junk2 * 4, System.IO.SeekOrigin.Current);
outlen = s.Length - (s.Position - 8L);
outpos = 0;
buffer[8] = (byte)s.ReadByte();
bufferptrin = 9;
bufferptrout = tpos;
pos = (int)s.Position;
}
示例4: ImageDirectory
public ImageDirectory (System.IO.Stream stream, uint start, long end, bool little)
{
this.start = start;
this.little = little;
this.stream = stream;
entry_list = new System.Collections.ArrayList ();
stream.Position = end - 4;
byte [] buf = new byte [10];
stream.Read (buf, 0, 4);
uint directory_pos = BitConverter.ToUInt32 (buf, 0, little);
DirPosition = start + directory_pos;
stream.Position = DirPosition;
stream.Read (buf, 0, 2);
Count = BitConverter.ToUInt16 (buf, 0, little);
for (int i = 0; i < Count; i++)
{
stream.Read (buf, 0, 10);
System.Console.WriteLine ("reading {0} {1}", i, stream.Position);
Entry entry = new Entry (buf, 0, little);
entry_list.Add (entry);
}
}
示例5: Upload
/// <summary>
/// Copies a stream to a Glacier vault archive
/// </summary>
/// <param name="stream">
/// The stream to read
/// </param>
/// <returns>
/// The total number of bytes read
/// </returns>
public Int64 Upload(Stream stream)
{
var streamLength = 0L;
for (; ; )
{
// if we have filled the current part, then upload it
if (this.partOffset == PartSize)
Flush();
// read the next block from the input stream
var read = stream.Read(
this.readBuffer,
0,
Math.Min(
this.readBuffer.Length,
PartSize - this.partOffset
)
);
if (read == 0)
break;
// write the results to the part buffer stream
this.partStream.Write(this.readBuffer, 0, read);
this.partOffset += read;
streamLength += read;
}
return streamLength;
}