Skip to content

Commit

Permalink
Fixed an issue causing ZipExtractor to fail with System.UnauthorizedA…
Browse files Browse the repository at this point in the history
…ccessException if the files it is trying to replace are hidden. This fixes #601.
  • Loading branch information
ravibpatel committed Mar 10, 2023
1 parent f746142 commit fc9686c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ There are two things you need to provide in XML file as you can see above.
<checksum algorithm="MD5">Update file Checksum</checksum>
````

You can also use the XML creator tool created by one of the user to create the XML file. You can download it from [here](https://github.com/DwainSnickles/AutoUpdater.NET.XML-Creator-master/blob/master/AutoUpdaterXML.zip).

### Adding one line to make it work

After you done creating and uploading XML file, It is very easy to add a auto update functionality to your application. First you need to add following line at the top of your form.
Expand Down
10 changes: 9 additions & 1 deletion ZipExtractor/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,15 @@ private void FormMain_Shown(object sender, EventArgs e)
{
Directory.CreateDirectory(parentDirectory);
}
entry.ExtractToFile(filePath, true);
using (Stream destination = File.Open(filePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None))
{
using Stream stream = entry.Open();
stream.CopyTo(destination);
stream.Flush();
destination.SetLength(destination.Position);
}
File.SetLastWriteTime(filePath, entry.LastWriteTime.DateTime);
}
notCopied = false;
}
Expand Down

0 comments on commit fc9686c

Please sign in to comment.