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

Commit

Permalink
SAI2 local paths fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Who cares committed Sep 1, 2018
1 parent fcac32e commit abfc8d5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
4 changes: 2 additions & 2 deletions SAI-Autosaver/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.6")]
[assembly: AssemblyFileVersion("1.3.6")]
[assembly: AssemblyVersion("1.3.7")]
[assembly: AssemblyFileVersion("1.3.7")]
[assembly: NeutralResourcesLanguage("en")]

27 changes: 22 additions & 5 deletions SAI-Autosaver/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,31 @@ public static string GetProjectAbsolutePath()
if (path.Contains('/'))
{
var pathSplit = path.Split('/').Select(x => x.Trim()).ToArray();
var principalSearcher = new PrincipalSearcher(new UserPrincipal(new PrincipalContext(ContextType.Machine)));

foreach (var principal in principalSearcher.FindAll())
if (pathSplit.Length == 2 && pathSplit[0].ToLower() == "desktop")
{
if (pathSplit[0] == principal.DisplayName || pathSplit[0] == principal.Name)
path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), pathSplit[1]);
}
else
{
var principalSearcher = new PrincipalSearcher(new UserPrincipal(new PrincipalContext(ContextType.Machine)));
var found = false;

foreach (var principal in principalSearcher.FindAll())
{
if (pathSplit[0] == principal.DisplayName || pathSplit[0] == principal.Name)
{
var userProfile = Path.Combine(Directory.GetParent(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)).ToString(), principal.Name);
path = Path.Combine(new string[] { userProfile }.Concat(pathSplit.Skip(1)).ToArray());

found = true;
break;
}
}

if (!found)
{
var userProfile = Path.Combine(Directory.GetParent(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)).ToString(), principal.Name);
path = Path.Combine(new string[] { userProfile }.Concat(pathSplit.Skip(1)).ToArray());
path = Path.Combine(new string[] { Environment.GetFolderPath(Environment.SpecialFolder.Desktop) }.Concat(pathSplit).ToArray());
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Setup/Setup.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -380,15 +380,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:SAI Autosaver"
"ProductCode" = "8:{B317BED4-B8FD-4638-9516-7F02A69E9C99}"
"PackageCode" = "8:{6743CC95-0312-4937-AF68-31B8F9C02791}"
"ProductCode" = "8:{189B6663-5EE8-464A-9F59-A65C541DA379}"
"PackageCode" = "8:{FE077F34-1563-45A0-88C2-6848415B8898}"
"UpgradeCode" = "8:{92B56287-C711-4BD0-90AD-48904A3FD4E1}"
"AspNetVersion" = "8:2.0.50727.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:FALSE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:TRUE"
"ProductVersion" = "8:1.3.6"
"ProductVersion" = "8:1.3.7"
"Manufacturer" = "8:SAI Autosaver"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:https://vk.com/rukifox"
Expand Down

0 comments on commit abfc8d5

Please sign in to comment.