|
1 | 1 |
|
| 2 | +Imports System |
2 | 3 | Imports System.IO |
3 | 4 | Imports System.Net.Http |
| 5 | +Imports System.Threading.Tasks |
| 6 | +Imports System.Windows.Forms |
| 7 | +Imports System.Reflection |
| 8 | +Imports System.Runtime.InteropServices |
4 | 9 |
|
5 | 10 | Imports CommunityToolkit.Mvvm.ComponentModel |
6 | 11 |
|
@@ -67,17 +72,41 @@ Public Class SteamFolder : Inherits CompressableFolder |
67 | 72 |
|
68 | 73 | End Function |
69 | 74 |
|
| 75 | + Public Shared Function GetAppRootPath() As String |
| 76 | + Try |
| 77 | + If AppContext.TryGetSwitch("System.AppContext.SingleFile", Nothing) Then |
| 78 | + Dim pathBuffer As New String(Chr(0), 260) |
| 79 | + Dim exePath As String = pathBuffer.TrimEnd(Chr(0)) |
| 80 | + Dim appRootPath As String = Path.GetDirectoryName(exePath) |
| 81 | + Return If(appRootPath.EndsWith("\"), appRootPath.TrimEnd("\"), appRootPath) |
| 82 | + Else |
| 83 | + Dim appRootPath As String = AppContext.BaseDirectory |
| 84 | + Return If(appRootPath.EndsWith("\"), appRootPath.TrimEnd("\"), appRootPath) |
| 85 | + End If |
| 86 | + Catch ex As Exception |
| 87 | + Return Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) |
| 88 | + End Try |
| 89 | + End Function |
| 90 | + |
70 | 91 | Public Shared Async Function GetSteamHeaderAsync(folder As SteamFolder) As Task |
71 | 92 |
|
72 | 93 | If folder.SteamAppID = 0 Then Return |
73 | 94 |
|
74 | 95 | Dim tempImg As BitmapImage = Nothing |
75 | 96 |
|
76 | | - Dim EnvironmentPath = Environment.GetEnvironmentVariable("IridiumIO", EnvironmentVariableTarget.User) |
77 | | - Dim imageDir = Path.Combine(EnvironmentPath, "CompactGUI", "SteamCache") |
| 97 | + Dim appRootPath As String = GetAppRootPath() |
| 98 | + Dim EnvironmentPath = Path.Combine(appRootPath, "data") |
| 99 | + Dim imageDir = Path.Combine(EnvironmentPath, "SteamCache") |
78 | 100 | Dim imagePath = Path.Combine(imageDir, $"{folder.SteamAppID}.jpg") |
79 | 101 |
|
80 | | - If Not Directory.Exists(imageDir) Then Directory.CreateDirectory(imageDir) |
| 102 | + Try |
| 103 | + Directory.CreateDirectory(imageDir) |
| 104 | + Catch ex As Exception |
| 105 | + EnvironmentPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "IridiumIO", "CompactGUI") |
| 106 | + imageDir = Path.Combine(EnvironmentPath, "SteamCache") |
| 107 | + imagePath = Path.Combine(imageDir, $"{folder.SteamAppID}.jpg") |
| 108 | + Directory.CreateDirectory(imageDir) |
| 109 | + End Try |
81 | 110 |
|
82 | 111 | If File.Exists(imagePath) Then |
83 | 112 | tempImg = LoadImageFromDisk(imagePath) |
|
0 commit comments