Beispiel #1
0
        private PluginInfo[] GetPlugins()
        {
            var validExtensions   = new[] { ".esl", ".esm", ".esp" };
            var fileInfos         = new System.IO.DirectoryInfo(dataPath).GetFiles();
            var filteredFileInfos = fileInfos.Where(fi => validExtensions.Contains(fi.Extension));
            var pluginInfos       = filteredFileInfos.Select(fi => GetPluginInfo(fi));

            return(pluginInfos.ToArray());
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            int daysOld = 7;
            string folder = "";
            string pattern = "*.*";
            System.IO.SearchOption searchOption = System.IO.SearchOption.TopDirectoryOnly;
            Arguments CommandLine = new Arguments(args);

            if (CommandLine["Help"] != null)
            {
                Console.Out.WriteLine("-Help, -Folder, -Pattern, -Days");
            }
            else
            {
                if (CommandLine["Subdir"] != null)
                {
                    // includeSubDirectories = true;
                    searchOption = System.IO.SearchOption.AllDirectories;
                }

                if (CommandLine["Folder"] != null)
                {
                    folder = CommandLine["Folder"];
                }
                else
                {
                    throw new MissingMemberException("Missing the Folder argument");
                }

                if (CommandLine["Pattern"] != null)
                {
                    pattern = CommandLine["Pattern"];
                }

                if (CommandLine["Days"] != null)
                {
                    daysOld = int.Parse(CommandLine["Days"]);
                }

                var CurrentTime = System.DateTime.UtcNow;
                var pre_matched_files = new System.IO.DirectoryInfo(folder).GetFiles(pattern, searchOption);
                var matched_files = pre_matched_files.Where(el => el.LastWriteTimeUtc.AddDays(daysOld) < CurrentTime).ToList();

                Console.Out.WriteLine(string.Format("Matched {0} files in folder {1}", matched_files.Count(),folder));
                foreach (var file in matched_files)
                {
                    Console.Out.WriteLine(string.Format("Deleting {0} ...", file.Name));
                    file.Delete();
                }

                Console.Out.WriteLine(string.Format("Deleted {0} files ", matched_files.Count()));
            }
        }
        public ActionResult ErrorLog(string log)
        {
            var logs = new System.IO.DirectoryInfo(Server.MapPath("~/App_Data")).GetFiles("*.log")
                       .OrderByDescending(o => o.LastWriteTime)
                       .Take(10)
                       .ToDictionary(f => f.Name, f => f.FullName);

            string[] selected = { "Select a log file to view..." };

            if (!string.IsNullOrWhiteSpace(log))
            {
                var file = logs.Where(l => l.Key == log).FirstOrDefault();
                selected = System.IO.File.ReadAllLines(file.Value);
            }

            ErrorLogModel model = new ErrorLogModel()
            {
                LogFiles    = logs.Select(l => l.Key).ToArray(),
                SelectedLog = selected
            };

            return(View("ErrorLog", model));
        }
        public ActionResult ErrorLog(string log)
        {
            var logs = new System.IO.DirectoryInfo(Server.MapPath("~/App_Data")).GetFiles("*.log")
                .OrderByDescending(o => o.LastWriteTime)
                .Take(10)
                .ToDictionary(f => f.Name, f => f.FullName);
            string[] selected = { "Select a log file to view..." };

            if (!string.IsNullOrWhiteSpace(log))
            {
                var file = logs.Where(l => l.Key == log).FirstOrDefault();
                selected = System.IO.File.ReadAllLines(file.Value);
            }

            ErrorLogModel model = new ErrorLogModel() {
                LogFiles = logs.Select(l => l.Key).ToArray(),
                SelectedLog = selected
            };

            return View("ErrorLog", model);
        }