From 7c4563bf9b18aa9dfaac6ad9f4b1df9af6319e74 Mon Sep 17 00:00:00 2001 From: pypy Date: Mon, 13 Jul 2020 21:30:47 +0900 Subject: [PATCH] change startup path #69 --- MainForm.cs | 2 +- SQLite.cs | 5 ++++- VRCXStorage.cs | 8 +++++--- VRCXVR.cs | 5 +++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/MainForm.cs b/MainForm.cs index f27a0765..6d9a3792 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -36,7 +36,7 @@ namespace VRCX catch { } - // Application.StartupPath + "/html/index.html" + // AppDomain.CurrentDomain.BaseDirectory + "/html/index.html" Browser = new ChromiumWebBrowser(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "html/index.html")) { DragHandler = new NoopDragHandler(), diff --git a/SQLite.cs b/SQLite.cs index f26e853d..b502c874 100644 --- a/SQLite.cs +++ b/SQLite.cs @@ -1,6 +1,8 @@ using CefSharp; +using System; using System.Collections.Generic; using System.Data.SQLite; +using System.IO; using System.Threading; namespace VRCX @@ -18,7 +20,8 @@ namespace VRCX public static void Init() { - m_Connection = new SQLiteConnection($"Data Source={Application.StartupPath}/VRCX.sqlite3;Version=3;PRAGMA locking_mode=NORMAL;PRAGMA cache_size=10000;PRAGMA temp_store=MEMORY;PRAGMA synchronous=OFF;PRAGMA journal_mode=MEMORY;PRAGMA busy_timeout=1000"); + var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "VRCX.sqlite3"); + m_Connection = new SQLiteConnection($"Data Source=\"{path}\";Version=3;PRAGMA locking_mode=NORMAL;PRAGMA cache_size=10000;PRAGMA temp_store=MEMORY;PRAGMA synchronous=OFF;PRAGMA journal_mode=MEMORY;PRAGMA busy_timeout=1000", true); m_Connection.Open(); } diff --git a/VRCXStorage.cs b/VRCXStorage.cs index 13d8c209..158080f7 100644 --- a/VRCXStorage.cs +++ b/VRCXStorage.cs @@ -3,9 +3,10 @@ // This work is licensed under the terms of the MIT license. // For a copy, see . +using System; using System.Collections.Generic; +using System.IO; using System.Threading; -using System.Windows.Forms; namespace VRCX { @@ -14,6 +15,7 @@ namespace VRCX public static VRCXStorage Instance { get; private set; } private static readonly ReaderWriterLockSlim m_Lock = new ReaderWriterLockSlim(); private static Dictionary m_Storage = new Dictionary(); + private static string m_JsonPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "VRCX.json"); private static bool m_Dirty; static VRCXStorage() @@ -26,7 +28,7 @@ namespace VRCX m_Lock.EnterWriteLock(); try { - JsonSerializer.Deserialize(Application.StartupPath + "/VRCX.json", ref m_Storage); + JsonSerializer.Deserialize(m_JsonPath, ref m_Storage); m_Dirty = false; } finally @@ -42,7 +44,7 @@ namespace VRCX { if (m_Dirty) { - JsonSerializer.Serialize(Application.StartupPath + "/VRCX.json", m_Storage); + JsonSerializer.Serialize(m_JsonPath, m_Storage); m_Dirty = false; } } diff --git a/VRCXVR.cs b/VRCXVR.cs index cd8ca05c..5c4f9cfb 100644 --- a/VRCXVR.cs +++ b/VRCXVR.cs @@ -10,6 +10,7 @@ using SharpDX.Direct3D11; using SharpDX.DXGI; using System; using System.Collections.Generic; +using System.IO; using System.Runtime.InteropServices; using System.Text; using System.Threading; @@ -65,8 +66,8 @@ namespace VRCX BindFlags = BindFlags.ShaderResource, CpuAccessFlags = CpuAccessFlags.Write }); - m_Browser1 = new Browser(m_Texture1, Application.StartupPath + "/html/vr.html?1"); - m_Browser2 = new Browser(m_Texture2, Application.StartupPath + "/html/vr.html?2"); + m_Browser1 = new Browser(m_Texture1, Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "html/vr.html?1")); + m_Browser2 = new Browser(m_Texture2, Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "html/vr.html?2")); m_Thread = new Thread(() => { var active = false;