public IActionResult List([FromRoute] string secret)
        {
            string errorMessage;

            if (IsEnabled(out errorMessage) == false)
            {
                return(Content(errorMessage));
            }

            DirectoryInfo di  = GetWorkFolder(secret);
            DateTime      now = DateTime.Now;

            List <FileInfo> fiInfos = new List <FileInfo>();

            if (di.Exists)
            {
                fiInfos.AddRange(di.GetFiles().OrderByDescending(t => t.CreationTime));
            }
            List <FileDownloadInfoModel> files = new List <FileDownloadInfoModel>();

            foreach (var fi in fiInfos)
            {
                TimeSpan deleteAfter;
                if (UploadUtil.CheckFileIsOld(fi, out deleteAfter))
                {
                    fi.Delete();
                    continue;
                }
                files.Add(new FileDownloadInfoModel
                {
                    Title       = fi.Name,
                    Id          = fi.Name,
                    Size        = Helper.GetReadableByteSize(fi.Length),
                    Time        = fi.CreationTime.ToString("yyyy-MM-dd HH:mm:ss"),
                    DeleteAfter = Helper.GetReadableTimeSpan(deleteAfter)
                });
            }

            ViewBag.LimitMb = LimitMb;
            ViewBag.Secret  = secret?.ToString();
            ViewBag.Items   = files;

            return(View());
        }
        public static void RemoveOldFiles()
        {
            DirectoryInfo diTemp = GetWorkTempFolder(null);
            DateTime      now    = DateTime.Now;
            {
                foreach (var dirInfo in diTemp.GetDirectories())
                {
                    if (dirInfo != null)
                    {
                        foreach (var fi2 in dirInfo.GetFiles())
                        {
                            DateTime lastWriteTime;
                            if (UploadUtil.CheckFileIsOld(fi2, out lastWriteTime))
                            {
                                logger.InfoFormat("Delete(1) {0} - {1}",
                                                  fi2.FullName, lastWriteTime.ToString("yyyy-MM-dd HH:mm"));
                                fi2.Delete();
                            }
                        }
                        if (dirInfo.GetFileSystemInfos("*.*", SearchOption.AllDirectories).Length == 0)
                        {
                            logger.Info("Delete(2) " + dirInfo.FullName);
                            //dirInfo.Delete();
                        }
                    }
                }
            }

            DirectoryInfo diWork = GetWorkFolder(null);
            {
                foreach (var fsi in diWork.GetFileSystemInfos())
                {
                    var diWorkSub = fsi as DirectoryInfo;
                    if (diWorkSub != null)
                    {
                        foreach (var fi2 in diWorkSub.GetFiles())
                        {
                            DateTime lastWriteTime;
                            if (UploadUtil.CheckFileIsOld(fi2, out lastWriteTime))
                            {
                                logger.Info("Delete(4) " + fi2.FullName);
                                fi2.Delete();
                            }
                        }
                        if (diWorkSub.GetFileSystemInfos("*.*", SearchOption.AllDirectories).Length == 0)
                        {
                            logger.Info("Delete(5) " + diWorkSub.FullName);
                            //diWorkSub.Delete();
                        }
                    }
                    else
                    {
                        DateTime lastWriteTime;
                        if (UploadUtil.CheckFileIsOld(fsi, out lastWriteTime))
                        {
                            logger.Info("Delete(6) " + fsi.FullName);
                            fsi.Delete();
                        }
                    }
                }
            }
        }