[exe] Use `Environment.CurrentDirectory` instead of overriding fs
This commit is contained in:
parent
b91c526d2e
commit
fee8fd9320
|
@ -1,65 +0,0 @@
|
||||||
using System.IO;
|
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace UptimeKuma {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Current Directory using App location
|
|
||||||
*/
|
|
||||||
public class Directory {
|
|
||||||
private static string baseDir;
|
|
||||||
|
|
||||||
public static string FullPath(string path) {
|
|
||||||
return Path.Combine(GetBaseDir(), path);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetBaseDir() {
|
|
||||||
if (baseDir == null) {
|
|
||||||
baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
|
||||||
}
|
|
||||||
return baseDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool Exists(string path) {
|
|
||||||
return System.IO.Directory.Exists(FullPath(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Delete(string path, bool recursive) {
|
|
||||||
System.IO.Directory.Delete(FullPath(path), recursive);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Move(string src, string dest) {
|
|
||||||
System.IO.Directory.Move(FullPath(src), FullPath(dest));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string[] GetDirectories(string path) {
|
|
||||||
return System.IO.Directory.GetDirectories(FullPath(path));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class File {
|
|
||||||
|
|
||||||
private static string FullPath(string path) {
|
|
||||||
return Directory.FullPath(path);
|
|
||||||
}
|
|
||||||
public static bool Exists(string path) {
|
|
||||||
return System.IO.File.Exists(FullPath(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FileStream Create(string path) {
|
|
||||||
return System.IO.File.Create(FullPath(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string ReadAllText(string path) {
|
|
||||||
return System.IO.File.ReadAllText(FullPath(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Delete(string path) {
|
|
||||||
System.IO.File.Delete(FullPath(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void WriteAllText(string path, string content) {
|
|
||||||
System.IO.File.WriteAllText(FullPath(path), content);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -21,6 +21,12 @@ namespace UptimeKuma {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main(string[] args) {
|
static void Main(string[] args) {
|
||||||
|
var cwd = Path.GetDirectoryName(Application.ExecutablePath);
|
||||||
|
|
||||||
|
if (cwd != null) {
|
||||||
|
Environment.CurrentDirectory = cwd;
|
||||||
|
}
|
||||||
|
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
Application.Run(new UptimeKumaApplicationContext());
|
Application.Run(new UptimeKumaApplicationContext());
|
||||||
|
|
|
@ -160,7 +160,6 @@
|
||||||
<Compile Include="DownloadForm.Designer.cs">
|
<Compile Include="DownloadForm.Designer.cs">
|
||||||
<DependentUpon>DownloadForm.cs</DependentUpon>
|
<DependentUpon>DownloadForm.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="FS.cs" />
|
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Version.cs" />
|
<Compile Include="Version.cs" />
|
||||||
|
|
Loading…
Reference in New Issue