Click here to Skip to main content
15,899,754 members
Home / Discussions / C#
   

C#

 
GeneralRe: How can i retry read current line at text file? Pin
OriginalGriff29-May-16 22:12
mveOriginalGriff29-May-16 22:12 
GeneralRe: How can i retry read current line at text file? Pin
Matt T Heffron31-May-16 8:52
professionalMatt T Heffron31-May-16 8:52 
This may or may not work depending on the version of the .NET framework.
It appears that at least up through .NET 4.5.1, the Position property of a FileStream returned only the information about how far the buffering had read.
C#
namespace ConsoleApplication15
{
  class Program
  {
    static void Main(string[] args)
    {
      using (System.IO.StreamReader reader = new System.IO.StreamReader(@"..\..\Program.cs"))
      {
        if (reader.EndOfStream)
          return; // empty stream (also, this preloads the buffer)
        System.Console.WriteLine("Stream.Position = {0}", reader.BaseStream.Position);
      }
      System.Console.ReadLine();
    }
  }
}

This outputs:
Stream.Position = 455

(But looking at the 4.6.1 source code for FileStream, it appears that it will give the correct Position based on the actual read position.)
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
- G.K. Chesterton

AnswerRe: How can i retry read current line at text file? Pin
koolprasad200329-May-16 19:30
professionalkoolprasad200329-May-16 19:30 
GeneralRe: How can i retry read current line at text file? Pin
OriginalGriff29-May-16 20:03
mveOriginalGriff29-May-16 20:03 
GeneralRe: How can i retry read current line at text file? Pin
koolprasad200329-May-16 20:08
professionalkoolprasad200329-May-16 20:08 
GeneralRe: How can i retry read current line at text file? Pin
Member 1243103929-May-16 20:28
Member 1243103929-May-16 20:28 
GeneralRe: How can i retry read current line at text file? Pin
koolprasad200329-May-16 22:56
professionalkoolprasad200329-May-16 22:56 
GeneralRe: How can i retry read current line at text file? Pin
Eddy Vluggen30-May-16 0:25
professionalEddy Vluggen30-May-16 0:25 
GeneralRe: How can i retry read current line at text file? Pin
OriginalGriff29-May-16 20:54
mveOriginalGriff29-May-16 20:54 
SuggestionRe: How can i retry read current line at text file? Pin
Richard Deeming1-Jun-16 1:59
mveRichard Deeming1-Jun-16 1:59 
QuestionGeometry problem with c# .net Pin
avisotorisher29-May-16 0:35
avisotorisher29-May-16 0:35 
AnswerRe: Geometry problem with c# .net Pin
Richard MacCutchan29-May-16 1:08
mveRichard MacCutchan29-May-16 1:08 
GeneralRe: Geometry problem with c# .net Pin
avisotorisher29-May-16 2:05
avisotorisher29-May-16 2:05 
GeneralRe: Geometry problem with c# .net Pin
Richard MacCutchan29-May-16 2:12
mveRichard MacCutchan29-May-16 2:12 
GeneralRe: Geometry problem with c# .net Pin
avisotorisher30-May-16 18:35
avisotorisher30-May-16 18:35 
AnswerRe: Geometry problem with c# .net Pin
Patrice T29-May-16 7:13
mvePatrice T29-May-16 7:13 
GeneralRe: Geometry problem with c# .net Pin
Sascha Lefèvre29-May-16 9:30
professionalSascha Lefèvre29-May-16 9:30 
GeneralRe: Geometry problem with c# .net Pin
Patrice T29-May-16 13:36
mvePatrice T29-May-16 13:36 
AnswerRe: Geometry problem with c# .net Pin
avisotorisher30-May-16 17:29
avisotorisher30-May-16 17:29 
QuestionLooking the best GPS tracking Application until now Pin
Dr Kasa29-May-16 0:12
Dr Kasa29-May-16 0:12 
AnswerRe: Looking the best GPS tracking Application until now Pin
Eddy Vluggen29-May-16 0:20
professionalEddy Vluggen29-May-16 0:20 
GeneralRe: Looking the best GPS tracking Application until now Pin
Dr Kasa20-Apr-17 3:34
Dr Kasa20-Apr-17 3:34 
AnswerRe: Looking the best GPS tracking Application until now Pin
PraveenDora31-May-16 6:41
PraveenDora31-May-16 6:41 
GeneralRe: Looking the best GPS tracking Application until now Pin
Dr Kasa20-Apr-17 3:33
Dr Kasa20-Apr-17 3:33 
QuestionSystem.Windows.Forms Issue Pin
jkadjthegamegadhguaet27-May-16 15:44
jkadjthegamegadhguaet27-May-16 15:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.