I think it has to overwrite the file.There should not be any problem.According
to me, the only way it can give an exception is, when the existed file
is read-only

Thanks,
Ram.


On Tue, Oct 6, 2009 at 7:39 AM, Benj Nunez <[email protected]> wrote:

>
> Hello everyone,
>
>
> I would just like to share with you my observation with the use of the
> File.WriteAllText().
> I have code like this:
>
> public bool dumpToFile(ref StringBuilder AData, String AFileNameStr)
> {
>   ...
>            string AppPath = Application.StartupPath;
>
>            AppPath += "\\";
>            try
>            {
>                File.WriteAllText(@AppPath + AFileNameStr,
> AData.ToString());
>                IsOk = true;
>            }
>            catch (System.ArgumentNullException)
>            {
>                throw;
>            }
>
>            ...
> }
>
>
> 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.).
>
> Any comments on this? I'm aware that I can use StreamWriter as a
> substitute. Your inputs
> are welcome.
>
>
>
>
>
>


-- 
S hrewd
 I mpartial
  T alented
    A lluring
     R esolute
       A ggressive
         M odern.

Mobile:-9885291971

Reply via email to