will he

will he

  • NA
  • 14
  • 0

How to update a record of a txt file in C# ?

Oct 3 2006 3:55 PM
Hi,

Is it possible to update a record of a txt file in C#? In VB, we can do:

Open inFile For Random As #1 Len = 1156
Put #1 , recNum, outLine
Close #1

Here recNum is the specific record number which we want to update, outLine is the new record.

My question is that in C# do we have any way to do it or not? Or C# have any other way to update a record just like update in DB file. 

So far, I can figure out a way is to write all the records from beginning to recNum -1, then write record recNum and then write the balance. finianlly delete the old file and rename the new file. This is very dummy way. I hope somebody can give me a better ideal.

Thanks you very much.


Answers (1)