KHO THƯ VIỆN 🔎

Thinking in C# phần 7

➤  Gửi thông báo lỗi    ⚠️ Báo cáo tài liệu vi phạm

Loại tài liệu:     PDF
Số trang:         80 Trang
Tài liệu:           ✅  ĐÃ ĐƯỢC PHÊ DUYỆT
 













Nội dung chi tiết: Thinking in C# phần 7

Thinking in C# phần 7

Random access with SeekThe Stream base class contains a method called Seek( ) that can be used to jump between records and data sections of known size

Thinking in C# phần 7 e (or sizes that can be computed by reading header data in the stream). The records don't have to be the same size; you just have to be able to determ

ine how big they are and where they are placed in the file. The Seeko method takes a long (implying a maximum tile size of 8 exabytes, which will hope Thinking in C# phần 7

fully suffice for a few years) and a value from the SeekOrigiu enumeration which can be Begin, Current, or End The Seekorigin value specifies the poin

Thinking in C# phần 7

t from which the seek jumps.Although Seek( ) IS defined in Stream, not all Streams support It (for instance, one can't “jump around" a network stream)

Random access with SeekThe Stream base class contains a method called Seek( ) that can be used to jump between records and data sections of known size

Thinking in C# phần 7 method which returns the current position in the Stream. If CanSeek is false and one of these methods is called, it will throw a NotSupportedExceptio

n Tins is poor design. Support for random access is based on type, not state, and should be specified in an interface (say, ISeekable) that is impleme Thinking in C# phần 7

nted by the appropriate subtypes of StreamIf you use SeekOrigin.End. you should use a negative number for the offset; performing a Seek( ) beyond the

Thinking in C# phần 7

end of the stream moves to the end of the file (i.e., ReadByte( ) will return a -1, etc ).This example shows the basic use of Stream.Seek( )://ỈC12:Fi

Random access with SeekThe Stream base class contains a method called Seek( ) that can be used to jump between records and data sections of known size

Thinking in C# phần 7 nd) ( src.Seek<-10, so) ;) else {494Thinking in c*ThtnkingIn.NETsrc.SeekdO, so);)int i - src.ReadByteo;Console. writeLme ("10 bytes from {0} is : {1}"

, so, (char) i);1public static void Main(string[] args){ foreach(string fName in args){ Filestream f null;try {f new Fllestream(fName, FlleMode.Open Thinking in C# phần 7

); Fibseek fs new Flbseek(f);fs.DoSeek(SeekOrigin.Begin) ;fs.DoSeek(SeekOrigin.End);f.Seek(12, SeekOrigin.Begin);fs.Doseek(Seekorigin.current);) catc

Thinking in C# phần 7

h (Exception ex) {Console.WriteLine(ex);} finally (f.Closet) ;I I . V V j}

Random access with SeekThe Stream base class contains a method called Seek( ) that can be used to jump between records and data sections of known size

Random access with SeekThe Stream base class contains a method called Seek( ) that can be used to jump between records and data sections of known size

Gọi ngay
Chat zalo
Facebook