在c#中filestream如何运用seek语句啊。详解
1个回答
展开全部
这个方法就是将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);
其中有两个参数,第一个参数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);
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询