mirror of
https://github.com/Stone-Red-Code/ClipCMD.git
synced 2026-09-04 00:46:10 +02:00
Store data in AppData
This commit is contained in:
+17
-6
@@ -1,15 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
|
||||
namespace ClipCMD;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
const string appName = "ClipCMD";
|
||||
|
||||
_ = new Mutex(true, appName, out bool createdNew);
|
||||
|
||||
if (!createdNew)
|
||||
{
|
||||
//App is already running! Exiting the application
|
||||
_ = MessageBox.Show($"Another instance of {appName} already running!", $"{appName} is already running!", MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
||||
Current.Shutdown();
|
||||
}
|
||||
|
||||
base.OnStartup(e);
|
||||
}
|
||||
}
|
||||
@@ -44,11 +44,16 @@ public partial class MainWindow : Window
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
string filePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
|
||||
string workPath = Path.GetDirectoryName(filePath) ?? "/";
|
||||
string applicationDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||
string folderPath = Path.Combine(applicationDataPath, "ClipCMD");
|
||||
|
||||
cmdPath = Path.Combine(workPath, "cmd.txt");
|
||||
fixPath = Path.Combine(workPath, "fix.txt");
|
||||
if (!Directory.Exists(folderPath))
|
||||
{
|
||||
_ = Directory.CreateDirectory(folderPath);
|
||||
}
|
||||
|
||||
cmdPath = Path.Combine(folderPath, "cmd.txt");
|
||||
fixPath = Path.Combine(folderPath, "fix.txt");
|
||||
}
|
||||
|
||||
protected override void OnSourceInitialized(EventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user