Click here to Skip to main content
15,915,019 members
Home / Discussions / C#
   

C#

 
GeneralRe: Problem calling dll from asp.net - workaround? Pin
totig7-Jan-05 0:41
totig7-Jan-05 0:41 
GeneralRe: Problem calling dll from asp.net - workaround? Pin
OmegaSupreme7-Jan-05 1:05
OmegaSupreme7-Jan-05 1:05 
GeneralInsert a line into the begining of the text file Pin
itssuk6-Jan-05 19:49
itssuk6-Jan-05 19:49 
GeneralRe: Insert a line into the begining of the text file Pin
Yulianto.6-Jan-05 21:22
Yulianto.6-Jan-05 21:22 
GeneralRe: Insert a line into the begining of the text file Pin
itssuk6-Jan-05 22:57
itssuk6-Jan-05 22:57 
GeneralRe: Insert a line into the begining of the text file Pin
Adam Goossens7-Jan-05 0:02
Adam Goossens7-Jan-05 0:02 
GeneralRe: Insert a line into the begining of the text file Pin
Stefan Troschuetz7-Jan-05 0:10
Stefan Troschuetz7-Jan-05 0:10 
GeneralRe: Insert a line into the begining of the text file Pin
Dave Kreskowiak7-Jan-05 3:10
mveDave Kreskowiak7-Jan-05 3:10 
In short, you cannot INSERT anything anywhere you want in a text file in a single, simple operation. Unless, of course, you want to APPEND to the end of the file.

If you want to insert text as the first lines in the file, you'll have to do one of two things:

1) Open the file; Read the entire contents of the text file into memory; Close the file; Reopen it as a new file; Write out the text you want to insert at the beginning of the file; Write out the contents that you saved; Close the file

2) Rename the file to some temporary name; Open a new file with the name you want; Write out the text you want to insert; Open the temporary file; Read it in, line by line, and write it out to the new file, line by line; Close both files

Method 1 will work very fast is better on samller files. Method 2 will work better for very large files, or files that you can't know the size of ahead of time, or files that exceed RAM capacity, but is slower.


RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

GeneralBest way to accomplish... Pin
Matt Newman6-Jan-05 15:03
Matt Newman6-Jan-05 15:03 
GeneralRe: Best way to accomplish... Pin
Christian Graus6-Jan-05 15:09
protectorChristian Graus6-Jan-05 15:09 
GeneralRe: Best way to accomplish... Pin
Matt Newman6-Jan-05 15:12
Matt Newman6-Jan-05 15:12 
GeneralRe: Best way to accomplish... Pin
Christian Graus6-Jan-05 21:14
protectorChristian Graus6-Jan-05 21:14 
GeneralRe: Best way to accomplish... Pin
Vega026-Jan-05 15:33
Vega026-Jan-05 15:33 
GeneralRe: Best way to accomplish... Pin
Matt Newman6-Jan-05 16:31
Matt Newman6-Jan-05 16:31 
GeneralRe: Best way to accomplish... Pin
Vega026-Jan-05 16:54
Vega026-Jan-05 16:54 
GeneralRe: Best way to accomplish... Pin
leppie6-Jan-05 20:27
leppie6-Jan-05 20:27 
Generalclear viewstate when postback Pin
esakal6-Jan-05 14:38
esakal6-Jan-05 14:38 
GeneralRe: clear viewstate when postback Pin
Heath Stewart6-Jan-05 14:52
protectorHeath Stewart6-Jan-05 14:52 
GeneralAngry DBA Pin
Anonymous6-Jan-05 14:26
Anonymous6-Jan-05 14:26 
GeneralImageList - MissingMainfest exception Pin
Christian Graus6-Jan-05 12:24
protectorChristian Graus6-Jan-05 12:24 
GeneralRe: ImageList - MissingMainfest exception Pin
Heath Stewart6-Jan-05 13:16
protectorHeath Stewart6-Jan-05 13:16 
GeneralRe: ImageList - MissingMainfest exception Pin
Christian Graus6-Jan-05 13:24
protectorChristian Graus6-Jan-05 13:24 
GeneralRe: ImageList - MissingMainfest exception Pin
Christian Graus6-Jan-05 13:49
protectorChristian Graus6-Jan-05 13:49 
GeneralRe: ImageList - MissingMainfest exception Pin
Heath Stewart6-Jan-05 13:59
protectorHeath Stewart6-Jan-05 13:59 
GeneralRe: ImageList - MissingMainfest exception Pin
Christian Graus6-Jan-05 14:08
protectorChristian Graus6-Jan-05 14:08 

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.