473,397 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

PROBLEM MOVING FILE POINTER

Following are my text file(IndxItms.txt) contents:
---------------------------------------------------
0000 0
0002 52
0020 260
0045 312
0051 364
0087 416
my C# code:
----------
StreamWriter sr_IndxItms = File.OpenText("\\My Documents\\IndxItms.txt");

MessageBox.Show(this.sr_IndxItms.ReadLine()); //output=> 0000 0

this.sr_IndxItms.BaseStream.Position = 0;
MessageBox.Show(this.sr_IndxItms.ReadLine()); //output=> 0002 52

this.sr_IndxItms.BaseStream.Seek(0, SeekOrigin.Begin);
MessageBox.Show(this.sr_IndxItms.ReadLine()); //output=> 0020 260
my question:
-----------

after statements:

this.sr_IndxItms.BaseStream.Position = 0;
or
this.sr_IndxItms.BaseStream.Seek(0, SeekOrigin.Begin);

file pointer must move to start of the file, but the output showing that
file pointer is not moving to start of the file,
instead reading from it's current position.

Why this is not workig? How can I move file pointer to the start of file?

Arif.
Nov 17 '05 #1
1 4709
Hi all,

problem solved. i have to call
this.sr_IndxItms.DiscardBufferedData();
to discard the buffered data before reading.

Arif.
"Arif" wrote:
Following are my text file(IndxItms.txt) contents:
---------------------------------------------------
0000 0
0002 52
0020 260
0045 312
0051 364
0087 416
my C# code:
----------
StreamWriter sr_IndxItms = File.OpenText("\\My Documents\\IndxItms.txt");

MessageBox.Show(this.sr_IndxItms.ReadLine()); //output=> 0000 0

this.sr_IndxItms.BaseStream.Position = 0;
MessageBox.Show(this.sr_IndxItms.ReadLine()); //output=> 0002 52

this.sr_IndxItms.BaseStream.Seek(0, SeekOrigin.Begin);
MessageBox.Show(this.sr_IndxItms.ReadLine()); //output=> 0020 260
my question:
-----------

after statements:

this.sr_IndxItms.BaseStream.Position = 0;
or
this.sr_IndxItms.BaseStream.Seek(0, SeekOrigin.Begin);

file pointer must move to start of the file, but the output showing that
file pointer is not moving to start of the file,
instead reading from it's current position.

Why this is not workig? How can I move file pointer to the start of file?

Arif.

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: trexim | last post by:
Hi, I am trying to create a Web Reference for CSTA using the URL http://www.ecma-international.org/standards/ecma-348/csta-wsdl/csta-wsdl-all-operations.wsdl Visual .Net complains that: "...
8
by: intrepid_dw | last post by:
Hello, all. I've created a C# dll that contains, among other things, two functions dealing with byte arrays. The first is a function that returns a byte array, and the other is intended to...
12
by: Felix85 | last post by:
here is my method for reading in a file: static room room::file2Room(int rnum){ ostringstream filename; filename << "../gamefiles/rooms/" << rnum << ".room"; ifstream...
6
by: Anil Gupte | last post by:
Here is my code: Dim fsReadStream As New FileStream(L3FileName, FileMode.Open, FileAccess.Read) Dim brReader As New BinaryReader(fsReadStream) Dim ByteArray() As Byte While brReader.PeekChar()...
2
by: ivotron | last post by:
Hi, I have very strange problem with std::fstream. I want to read a simple two-column space-separated file with the following code: #include <iostream> #include <fstream> int main() { ...
6
by: per9000 | last post by:
An interesting/annoying problem. I created a small example to provoke an exception I keep getting. Basically I have a C-struct (Container) with a function-pointer in it. I perform repeated calls...
7
by: souravmallik | last post by:
Hello, I'm facing a big logical problem while writing a parser in VC++ using C. I have to parse a file in a chunk of bytes in a round robin fashion. Means, when I select a file, the parser...
2
by: davidson1 | last post by:
Hai friends..for menu to use in my website..i found in one website....pl look below website.... http://www.dynamicdrive.com/dynamicindex1/omnislide/index.htm i downloaded 2 files.... ...
2
by: geseeker | last post by:
Hi, i want to move the file pointer to the last 128th byte, so i can read the ID3V1 tag in an mp3 file. Here's my code to test the result of moving the file pointer: #include <iostream> #include...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.