Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

Commit

Permalink
Truncate the original file before overwriting it
Browse files Browse the repository at this point in the history
If you opened a file that contained "AAAAA" and edited it to contain "BBB",
GitPad would create a file that contained "BBBAA". Now the original file gets
completely truncated before the new contents are laid down, so you'll end up
with "BBB" as expected.
  • Loading branch information
aroben committed Mar 8, 2012
1 parent dc5be51 commit e2195e5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Program.cs
Expand Up @@ -98,7 +98,7 @@ public static int Main(string[] args)

static void WriteStringToFile(string path, string fileData, LineEndingType lineType)
{
using(var of = File.OpenWrite(path))
using(var of = File.Open(path, FileMode.Create))
{
var buf = Encoding.UTF8.GetBytes(ForceLineEndings(fileData, lineType));
of.Write(buf, 0, buf.Length);
Expand Down

0 comments on commit e2195e5

Please sign in to comment.