unable to overwrite file using streamwriter despite append= false, without closing file

前端 未结 2 875
野趣味
野趣味 2021-01-27 08:24

using C# VS 2010, windows forms. My goal is to open and close the file only once and \"overwrite\" it multiple times. I never want to append. The reason for opening and closing

2条回答
  •  情书的邮戳
    2021-01-27 08:33

    You need to use

    FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write);

提交回复
热议问题