diff --git a/SunnyUI/Common/UDir.cs b/SunnyUI/Common/UDir.cs
index 16dbdf9d..d9257fc2 100644
--- a/SunnyUI/Common/UDir.cs
+++ b/SunnyUI/Common/UDir.cs
@@ -19,6 +19,7 @@
* 2020-01-01: V2.2.0 增加文件说明
******************************************************************************/
+using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
@@ -31,6 +32,48 @@ namespace Sunny.UI
///
public static class DirEx
{
+ ///
+ /// 创建一个目录
+ ///
+ /// 目录的绝对路径
+ public static bool CreateDir(string dir)
+ {
+ if (dir.IsNullOrEmpty())
+ {
+ throw new ArgumentNullException(dir, "目录不能为空。");
+ }
+
+ if (!Path.IsPathRooted(dir))
+ {
+ throw new ArgumentException(dir, "不包含根路径。");
+ }
+
+ //
+ //
+ try
+ {
+ if (!Directory.Exists(dir))
+ {
+ Directory.CreateDirectory(dir);
+ }
+
+ return Directory.Exists(dir);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ return false;
+ }
+ }
+
+ ///
+ /// 返回当前基目录
+ ///
+ /// 基目录
+ public static string CurrentDir()
+ {
+ return AppDomain.CurrentDomain.BaseDirectory.DealPath();
+ }
///
/// 选择文件夹
///
diff --git a/SunnyUI/Common/UGif.cs b/SunnyUI/Common/UGif.cs
index dd6009e9..8582d19a 100644
--- a/SunnyUI/Common/UGif.cs
+++ b/SunnyUI/Common/UGif.cs
@@ -37,6 +37,7 @@
using System;
using System.Drawing;
using System.Drawing.Imaging;
+using System.IO;
using System.Windows.Forms;
namespace Sunny.UI
@@ -55,7 +56,7 @@ namespace Sunny.UI
timer = new Timer();
timer.Tick += Timer_Tick;
- if (FileEx.Exists(fileName))
+ if (File.Exists(fileName))
{
Image = Image.FromFile(fileName);
}
diff --git a/SunnyUI/Common/USevenZip.cs b/SunnyUI/Common/USevenZip.cs
index e6c9b0fd..c7ff443d 100644
--- a/SunnyUI/Common/USevenZip.cs
+++ b/SunnyUI/Common/USevenZip.cs
@@ -19,11 +19,8 @@
* 2020-01-01: V2.2.0 增加文件说明
******************************************************************************/
-using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.IO;
-using System.Text;
namespace Sunny.UI
{
@@ -189,67 +186,5 @@ namespace Sunny.UI
return true;
}
-
- ///
- /// 压缩数组
- ///
- /// 数组
- /// 结果
- public static byte[] Compress(byte[] input)
- {
- string filename = FileEx.TempFileName();
- string filename7z = FileEx.TempFileName();
- File.WriteAllBytes(filename, input);
- ZipFile(filename, filename7z);
- byte[] bts = File.ReadAllBytes(filename7z);
- FileEx.TryDelete(filename);
- FileEx.TryDelete(filename7z);
- return bts;
- }
-
- ///
- /// 解压缩数组
- ///
- /// 数组
- /// 结果
- public static byte[] Decompress(byte[] input)
- {
- string zipfile = FileEx.TempFileName();
- File.WriteAllBytes(zipfile, input);
-
- string unzipDir = DirEx.TempRandomPath();
- UnZipFile(zipfile, unzipDir);
- string[] fall = Directory.GetFiles(unzipDir, "*.*", SearchOption.TopDirectoryOnly);
- string unzipfile = fall[0];
- byte[] bts = File.ReadAllBytes(unzipfile);
- FileEx.TryDelete(unzipfile);
- FileEx.TryDelete(zipfile);
- DirEx.TryDelete(unzipDir);
- return bts;
- }
-
- ///
- /// 压缩字符串
- ///
- /// 字符串
- /// 结果
- public static string Compress(string input)
- {
- byte[] inputBytes = Encoding.Default.GetBytes(input);
- byte[] result = Compress(inputBytes);
- return Convert.ToBase64String(result);
- }
-
- ///
- /// 解压缩字符串
- ///
- /// 字符串
- /// 结果
- public static string Decompress(string input)
- {
- byte[] inputBytes = Convert.FromBase64String(input);
- byte[] depressBytes = Decompress(inputBytes);
- return Encoding.Default.GetString(depressBytes);
- }
}
}
\ No newline at end of file