Fix for uninstalling in admin folder

Make sure it doesn't just have the read-only attribute. If it does and
we have admin. privileges, strip all of the files in the client's
install path so that we can proceed and continue the uninstallation
process.
This commit is contained in:
yankejustin 2015-08-26 14:15:14 -04:00
parent 6dbb5bface
commit 5dc8c0b07f
1 changed files with 28 additions and 0 deletions

View File

@ -25,6 +25,34 @@ namespace xClient.Core.Installation
try
{
DirectoryInfo dir = new DirectoryInfo(ClientData.InstallPath);
if (dir.Exists)
{
// Directory is marked as read-only, so we must remove it.
if ((dir.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
{
if (WindowsAccountHelper.GetAccountType() == "Admin")
{
foreach (FileInfo file in dir.GetFiles())
{
try
{
// Try to set the files in the folder to normal so they can be deleted.
file.Attributes = FileAttributes.Normal;
}
catch
{ }
}
}
else
{
// We need admin privileges to strip this directory of the read-only attribute...
return;
}
}
}
string batchFile = FileHelper.CreateUninstallBatch(Settings.HIDEFILE);
if (string.IsNullOrEmpty(batchFile)) return;