Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
StreamWriter Error
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01448574
Message ID:
01448661
Vues:
23
>I am using a StreamReader to read through a file. When I find the phrase I'm looking for, I then replace it with some other text. It is all appended to a string. I then close the StreamReader, and attempt to replace the file's contents with the new stirng using a streamwriter.
>
>When I do
>
>
>.
>.
>.
>
>rdr.Close();
>
>StreamWriter wr = new StreamWriter(FileName);
>wr.Write(NewText);
>wr.Close();
>
>
>It errors on the StreamWriter saying the file is in use. You can see the Reader is closed.

put a messagebox or a Thread.Sleep between rdr.Close(); and StreamWriter wr = new StreamWriter(FileName); to see if it is a timing issue. You don't give the reader a whole lot of time to close before you open it.

Einar
Semper ubi sub ubi.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform