Skip to content

Commit

Permalink
Fix: Detect Steam screenshots folder from registry (#886)
Browse files Browse the repository at this point in the history
  • Loading branch information
ScrapW committed Aug 29, 2024
1 parent 59237b5 commit c50a879
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions Dotnet/AppApi/Folders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Runtime.InteropServices;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Microsoft.Win32;

namespace VRCX
{
Expand Down Expand Up @@ -52,16 +53,41 @@ public string GetVRChatPhotosLocation()
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "VRChat");
}

private string GetSteamUserdataPathFromRegistry()
{
string steamUserdataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), @"Steam\userdata");

try
{
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\Valve\Steam"))
{
if (key != null)
{
object o = key.GetValue("InstallPath");
if (o != null)
{
steamUserdataPath = Path.Combine(o.ToString(), @"userdata");
}
}
}
}
catch
{
}

return steamUserdataPath;
}

public string GetVRChatScreenshotsLocation()
{
// program files steam userdata screenshots
var steamPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), @"Steam\userdata");
var steamUserdataPath = GetSteamUserdataPathFromRegistry();
var screenshotPath = string.Empty;
var latestWriteTime = DateTime.MinValue;
if (!Directory.Exists(steamPath))
if (!Directory.Exists(steamUserdataPath))
return screenshotPath;

var steamUserDirs = Directory.GetDirectories(steamPath);
var steamUserDirs = Directory.GetDirectories(steamUserdataPath);
foreach (var steamUserDir in steamUserDirs)
{
var screenshotDir = Path.Combine(steamUserDir, @"760\remote\438100\screenshots");
Expand Down

0 comments on commit c50a879

Please sign in to comment.