I am happy that you have already understood my first answer and pointing to
the stringbuilder :)

2009/10/11 Benj Nunez <[email protected]>

>
> Never mind. I figured it out already. It was the stringbuilder causing
> the problem. I had to use its
> .Remove() routine to remove the last collection used prior to sending
> them off to dumpToFile().
>
>
> Thanks for your help everyone!
>
>
>
> Cheers!
>
>
>
> Benj
>
>
>
>
> On Oct 10, 6:04 pm, Benj Nunez <[email protected]> wrote:
> > 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 <[email protected]> wrote:
> >
> > > On Mon, Oct 5, 2009 at 10:09 PM, Benj Nunez <[email protected]>
> 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.
> > > *
> > > So I guess the question is, how did it 'apparently not' in your case.
> It did
> > > in all my test cases:
> > >          http://dotnetdevelopment.pastebin.com/f17b0514b
> > > I stepped thru each write, and after the debug text came up, I checked
> the
> > > file.
>

Reply via email to