Click here to Skip to main content
15,922,894 members
Home / Discussions / C#
   

C#

 
AnswerRe: Finding the MDAC Version programmically? Pin
Paul Conrad30-Jul-07 14:06
professionalPaul Conrad30-Jul-07 14:06 
AnswerRe: Finding the MDAC Version programmically? Pin
Vasudevan Deepak Kumar30-Jul-07 17:51
Vasudevan Deepak Kumar30-Jul-07 17:51 
GeneralRe: Finding the MDAC Version programmically? Pin
BssDeveloper30-Jul-07 21:44
BssDeveloper30-Jul-07 21:44 
Questionnotification of change Pin
likefood30-Jul-07 12:28
likefood30-Jul-07 12:28 
QuestionWeb.Config file problem... Any Help? Pin
rashadaliarshad30-Jul-07 11:40
rashadaliarshad30-Jul-07 11:40 
AnswerRe: Web.Config file problem... Any Help? Pin
Edwin Syarief30-Jul-07 15:54
Edwin Syarief30-Jul-07 15:54 
QuestionBinary File Access Pin
JamesBarnes30-Jul-07 10:09
JamesBarnes30-Jul-07 10:09 
AnswerRe: Binary File Access Pin
Luc Pattyn30-Jul-07 10:27
sitebuilderLuc Pattyn30-Jul-07 10:27 
Hi,

you have confused yourself I am afraid, I'll annotate your code with
the offset each reader/writer has:

FileStream fs = new FileStream("test.dat",FileMode.OpenOrCreate,FileAccess.ReadWrite);
BinaryWriter bw = new BinaryWriter(fs);   // 0
BinaryReader br = new BinaryReader(fs);   // 0

bw.Seek(10,SeekOrigin.Begin);  // 10
bw.Write("hello World");       // 10+stringlength 

bw.Seek(-10, SeekOrigin.End);  // 10 before the end, that's somewhere in the string
                               // but this statement has no purpose, bw is not
                               // used afterwards

string myString = br.ReadString(); // this reads starting at position 0



In summary: you can attach as many streams as you want to a single file.
Each stream will see the same data, but have its own pointer pointing into that data.
you skipped 10 bytes (in a new file, those bytes remain filled with zeroes),
then write a string, then move somewhat back.
The reading stream has not moved yet, so it reads at position 0, and finds a lot
of zeroes, which results in an empty string.

Normally you don't jump around like that. You either write (or read) sequentially,
or you move purposely around (say to skip records you are not interested in).

Hope this helps.





GeneralRe: Binary File Access Pin
PIEBALDconsult30-Jul-07 10:44
mvePIEBALDconsult30-Jul-07 10:44 
GeneralRe: Binary File Access Pin
Luc Pattyn30-Jul-07 10:51
sitebuilderLuc Pattyn30-Jul-07 10:51 
AnswerRe: Binary File Access Pin
PIEBALDconsult30-Jul-07 10:37
mvePIEBALDconsult30-Jul-07 10:37 
GeneralRe: Binary File Access Pin
JamesBarnes30-Jul-07 11:17
JamesBarnes30-Jul-07 11:17 
QuestionNewspaper columns in control Pin
Elvis_Pretzelator30-Jul-07 9:18
Elvis_Pretzelator30-Jul-07 9:18 
JokeRe: Newspaper columns in control Pin
BoneSoft30-Jul-07 9:22
BoneSoft30-Jul-07 9:22 
AnswerRe: Newspaper columns in control Pin
Luc Pattyn30-Jul-07 9:31
sitebuilderLuc Pattyn30-Jul-07 9:31 
AnswerRe: Newspaper columns in control Pin
ekynox30-Jul-07 23:53
ekynox30-Jul-07 23:53 
AnswerRe: Gridview column data [modified] Pin
Herman<T>.Instance31-Jul-07 3:08
Herman<T>.Instance31-Jul-07 3:08 
QuestionSQL Data Pin
Saiyed Alam30-Jul-07 8:30
Saiyed Alam30-Jul-07 8:30 
AnswerRe: SQL Data Pin
BoneSoft30-Jul-07 9:55
BoneSoft30-Jul-07 9:55 
QuestionTab Order Pin
Saiyed Alam30-Jul-07 8:08
Saiyed Alam30-Jul-07 8:08 
AnswerRe: Tab Order Pin
Martin#30-Jul-07 8:09
Martin#30-Jul-07 8:09 
GeneralRe: Tab Order Pin
Saiyed Alam30-Jul-07 8:15
Saiyed Alam30-Jul-07 8:15 
AnswerRe: Tab Order Pin
Luis Alonso Ramos30-Jul-07 8:44
Luis Alonso Ramos30-Jul-07 8:44 
AnswerRe: Tab Order Pin
Paul Conrad30-Jul-07 10:44
professionalPaul Conrad30-Jul-07 10:44 
QuestionReference as a 'pointer' to a value type Pin
kildareflare30-Jul-07 7:37
kildareflare30-Jul-07 7:37 

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.