Set position in Stream

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Feb 2008
Posts: 517
Reputation: Jennifer84 is an unknown quantity at this point 
Solved Threads: 1
Jennifer84 Jennifer84 is offline Offline
Posting Pro

Set position in Stream

 
0
  #1
Oct 6th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 517
Reputation: Jennifer84 is an unknown quantity at this point 
Solved Threads: 1
Jennifer84 Jennifer84 is offline Offline
Posting Pro

Re: Set position in Stream

 
0
  #2
Oct 6th, 2008
Found the solution here.
  1. sr->BaseStream->Seek(Pos, System::IO::SeekOrigin::Begin);
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC