123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- using PDF_Office.Properties;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PDF_Office.Helper
- {
-
-
-
-
-
- public class CacheFilePath
- {
- private static readonly CacheFilePath instance = new CacheFilePath();
-
-
-
- List<string> CustomStamp = new List<string> { "CustomStamp" };
- List<string> SignatureFreeHand = new List<string> { "Signature" ,"FreeHand" };
- List<string> SignatureStamp = new List<string> { "Signature", "Stamp" };
- public static CacheFilePath Instance => instance;
- private CacheFilePath()
- {
- }
-
-
-
- public string CustomStampPath
- {
- get
- {
- return CreateCacheDirectory(CustomStamp);
- }
- }
-
-
-
- public string SignatureStampPath
- {
- get
- {
- return CreateCacheDirectory(SignatureStamp);
- }
- }
-
-
-
- public string SignatureFreeHandPath
- {
- get
- {
- return CreateCacheDirectory(SignatureFreeHand);
- }
- }
-
-
-
-
-
- private string CreateCacheDirectory(List<string> directoryName)
- {
- try
- {
- string Path = App.CurrentPath;
- for (int i = 0; i < directoryName.Count; i++)
- {
- Path = System.IO.Path.Combine(Path, directoryName[i]);
- }
-
- System.IO.DirectoryInfo directoryInfo = System.IO.Directory.CreateDirectory(Path);
- if (directoryInfo.Exists
- && (directoryInfo.Attributes & System.IO.FileAttributes.ReadOnly) != System.IO.FileAttributes.ReadOnly
- && (directoryInfo.Attributes & System.IO.FileAttributes.Hidden) != System.IO.FileAttributes.Hidden
- )
- {
- return Path;
- }
- else
- {
- return "";
- }
- }
- catch (Exception)
- {
- return "";
- }
- }
-
-
-
-
- public void AddToDeleteFiles(string file)
- {
-
- try
- {
- if (!Settings.Default.AppProperties.NeedToDeletePath.Contains(file))
- {
- Settings.Default.AppProperties.NeedToDeletePath.Add(file);
- }
- Settings.Default.Save();
-
- Settings.Default.Reload();
- }
- catch { }
- }
- public void AddToDeleteFiles(List<string> files)
- {
- foreach(string file in files)
- {
- AddToDeleteFiles(file);
- }
- }
-
-
-
- public void ClearDeleteFiles()
- {
- try
- {
- foreach (string file in Settings.Default.AppProperties.NeedToDeletePath)
- {
- if (File.Exists(file))
- {
- File.Delete(file);
- }
- }
- Settings.Default.AppProperties.NeedToDeletePath.Clear();
- }
- catch { }
- }
- }
- }
|