Example #1
0
        public static string GetOriginPath(string filename)
        {
            string appPath;

            if (MemoryCacheHelper.Contains(filename) == false)
            {
                appPath = PlatformServices.Default.Application.ApplicationBasePath;           //Microsoft.DotNet.PlatformAbstractions.ApplicationEnvironment.ApplicationBasePath;

                ErrorLog(string.Format("ApplicationBasePath = {0} line 2323 iuiu", appPath)); //-----------------------------------test
                string pathfilename = Path.Combine(appPath, filename);
                if (!File.Exists(pathfilename))
                {
                    System.Reflection.Assembly curPath = System.Reflection.Assembly.GetExecutingAssembly();
                    appPath = curPath.CodeBase;
                    if (appPath.ToLower().StartsWith("file"))
                    {
                        Uri uri = new Uri(appPath);
                        appPath = uri.LocalPath;
                    }
                    appPath      = Path.GetFullPath(appPath);
                    appPath      = PathRemoveBin(appPath);
                    pathfilename = Path.Combine(appPath, filename);
                    ErrorLog(string.Format("GetExecutingAssembly::CodeBase; = {0} line 789 ghj", appPath)); //-----------------------------------test
                    //-----------------------------------------------------------------------------------------------------
                    if (!File.Exists(pathfilename))
                    {
                        appPath = Path.GetFullPath(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
                        appPath = Path.GetDirectoryName(appPath);
                        ErrorLog(string.Format("GetCurrentProcess::MainModule; = {0} line 455 xfv", appPath));//-----------------------------------test
                    }
                    DateTimeOffset thisOffsetTime = DateTime.Now.AddHours(20);
                    MemoryCacheHelper.Set(filename, appPath, thisOffsetTime);
                    return(appPath);
                }
                else
                {
                    DateTimeOffset thisOffsetTime = DateTime.Now.AddHours(20);
                    MemoryCacheHelper.Set(filename, appPath, thisOffsetTime);
                    return(appPath);
                }
            }
            else
            {
                appPath = MemoryCacheHelper.GetCacheItem <string>(filename);
                return(appPath);
            }
        }