Thanks for responding. I read your source code. My expected output is
that since
your code has overwritten the same file twice, it should return the
last line only:
"File #1 testing.Oooh, you make me live."
Btw, if I have a file Name that is not a const, would that make a
difference? I happen to
save the file with a the current date *for each type it encounters*
like this:
StringBuilder sb = new StringBuilder();
sb.Append("CVM for ").Append(AType).Append(" ").
Append(Utils.FormattedDate(DateTime.Now.ToString())).
Append(".txt");
try
{
IsOk = service.dumpToFile(ref AData, sb.ToString
()); // ouput is "cvm for <type> mmddyyyy.txt".
}
...
<type> denotes some status (e.g. "new entry", "new shipment",
"replacement", etc.).
The seconds part is not included because obviously each time you call
dumpToFile(), you'll be
creating a lot of *.txt files which I don't want. That's the reason
why I need the File.WriteAllText() to overwrite
whatever's in the file and replace it with the new one. Instead, it's
appending them. :(
Any tips?
On Oct 9, 1:23 am, Peter Smith <
psmith.w...@gmail.com> wrote:
> On Mon, Oct 5, 2009 at 10:09 PM, Benj Nunez <
benjnu...@gmail.com> wrote:
>
> > I'm expecting that every time I run the dumpToFile() method it overwrites
> > the file
> > that already exists. Well, apparently in my case it did not (although the
> > documentation says it can.).
>
> The documentation actually says it WILL overwrite a file that exists, not
> that it can. 'can' implies that there are times that it 'cannot'.
>
> *public static void WriteAllText(string path, string contents)
> Member of System.IO.File
>
> Summary:
> Creates a new file, writes the specified string to the file, and then closes
> the file. If the target file already exists, it is overwritten.
> *