Answer the question
In order to leave comments, you need to log in
StreamReader how to change position?
Hello.
It is necessary to change the position in the stream, immediately, for example, to the 100th byte, but I can’t find examples where someone changed the position at all, it says that BaseStream.Position can both be read and set its own value, but when setting it, I get errors:
System.InvalidOperationException: You cannot modify the position of a FtpDataStream. This property is updated as data is read or written to the stream.
at FluentFTP.FtpDataStream.set_Position(Int64 value)
var client = await FTPConnect(userData);
using (StreamReader sr = new StreamReader(await client.OpenReadAsync(path), Encoding.UTF8))
{
try
{
sr.BaseStream.Position = Convert.ToInt64(offset); // Convert.ToInt64, поскольку нужно long
// for (int i = 0; i != offset; i++) sr.Read(); // Сделал с циклом, но не думаю что это хорошо
Console.WriteLine("#" + sr.BaseStream.Position + "\n" + sr.ReadToEnd() + "\n#"+sr.BaseStream.Position);
}
finally
{
sr.Close();
}
}
Answer the question
In order to leave comments, you need to log in
The download start position must be specified in the "ContentOffset" property of the "FtpWebRequest" object:
https://msdn.microsoft.com/en-us/library/system.ne...
The Stream does not need to be touched. There will already be data from the position we need.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question