943,754 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 1885
  • C++ RSS
Oct 6th, 2008
0

Set position in Stream

Expand Post »
When reading a txt file I am using .seekg to set the startpoint in the file to read from.
linepos has a value: 1002106
First I wonder what this value stands for excatly. As I have understand this is how many characters forward in the file that will be the absolute position from where the reading will start.
Now I am using StreamReader wich also has the ->Seek wich needs 2 arguments.
However when I am trying to put a startposition like this it will not compile.
What I wonder is how I can use the Pos Value to put this to ->Seek( , );

//File1.seekg Seek to right point in file to start reading from
File1.seekg( linepos );

int Pos = linepos; //Pos gives a value of 1002106

StreamReader^ sr = gcnew StreamReader(FileToRead);	
sr->BaseStream->Seek(0, Pos15);

// ::SeekOrigin might need to be used in any way
sr->BaseStream->Seek(0, System::IO::SeekOrigin::Begin = Pos15);
Last edited by Jennifer84; Oct 6th, 2008 at 4:09 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 1
Posting Pro
Jennifer84 is offline Offline
563 posts
since Feb 2008
Oct 6th, 2008
0

Re: Set position in Stream

Found the solution here.
C++ Syntax (Toggle Plain Text)
  1. sr->BaseStream->Seek(Pos, System::IO::SeekOrigin::Begin);
Reputation Points: 10
Solved Threads: 1
Posting Pro
Jennifer84 is offline Offline
563 posts
since Feb 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: *this problem (help?)
Next Thread in C++ Forum Timeline: Help With FUNCTion;





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC