中易网

在c#中filestream如何运用seek语句啊。详解

答案:1  悬赏:60  
解决时间 2021-01-19 00:13
  • 提问者网友:棒棒糖
  • 2021-01-17 23:22
在c#中filestream如何运用seek语句啊。详解
最佳答案
  • 二级知识专家网友:等灯
  • 2021-01-17 23:34
这个方法就是将FileStream流当前的位置进行重新设置。
其中有两个参数,第一个参数long offset,相对于第二个参的偏移量
第二个参数 SeekOrigin origin,这个参数是相对哪里,其中有枚举:开始位置、当前位置、未尾位置

// 摘要:
// Provides the fields that represent reference points in streams for seeking.
[Serializable]
[ComVisible(true)]
public enum SeekOrigin
{
// 摘要:
// Specifies the beginning of a stream.
Begin = 0,
//
// 摘要:
// Specifies the current position within a stream.
Current = 1,
//
// 摘要:
// Specifies the end of a stream.
End = 2,
}

//
// 摘要:
// Sets the current position of this stream to the given value.
//
// 参数:
// offset:
// The point relative to origin from which to begin seeking.
//
// origin:
// Specifies the beginning, the end, or the current position as a reference
// point for origin, using a value of type System.IO.SeekOrigin.
//
// 返回结果:
// The new position in the stream.
//
// 异常:
// System.IO.IOException:
// An I/O error occurs.
//
// System.NotSupportedException:
// The stream does not support seeking, such as if the FileStream is constructed
// from a pipe or console output.
//
// System.ArgumentException:
// Attempted seeking before the beginning of the stream.
//
// System.ObjectDisposedException:
// Methods were called after the stream was closed.
public override long Seek(long offset, SeekOrigin origin);
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息