using System;
using System.IO;
using System.Reflection;

namespace TSManagementApp.Utils
{
    public static class SystemUtils
    {
        public static string UserLocalAppDirectory
        {
            get
            {
                string localAppDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                    System.Reflection.Assembly.GetExecutingAssembly().GetName().Name);

                //pokud složka neexistuje, vytvořit
                DirectoryInfo dir = new DirectoryInfo(localAppDirectory);
                if (!dir.Exists)
                {
                    dir.Create();
                }

                return localAppDirectory;
            }
        }

        public static string AssemblyDirectory
        {
            get
            {
                string codeBase = Assembly.GetExecutingAssembly().CodeBase;
                UriBuilder uri = new UriBuilder(codeBase);
                string path = Uri.UnescapeDataString(uri.Path);
                return Path.GetDirectoryName(path) + @"\";
            }
        }
    }
}
