private static void CompressNetwork(string Prefix, List <string> FileList) { List <string> CompressList = new List <string>(); foreach (string CurFile in FileList) { string DateText = CurFile.Substring(CurFile.Length - 15, 8); if (!CompressList.Contains(DateText)) { CompressList.Add(DateText); } } if (CompressList.Count > 1) { // We don't want to compress todays, only past dates CompressList.RemoveAt(CompressList.Count - 1); foreach (string DateToCompress in CompressList) { CompressDate(Prefix, DateToCompress, FileList); } } else { AppLog.WriteLine(5, "STATUS", "Nothing to compress..."); } }
public void CanReadAniCursors() { InstalledFilesTestData.ReadFiles(".cur", _output, entry => { var curFile = CurFile.FromFileSystemEntry(entry); Assert.NotNull(curFile); Assert.True(curFile.Image.Width > 0); }); }
public void Convert(IApplication app) { try { string[] Files = Directory.GetFiles(@".\Configs"); foreach (string CurFile in Files) { if (CurFile.Contains(".anom")) { string NewName = Path.ChangeExtension(CurFile, ".loli"); File.Move(CurFile, NewName); } } app.Logger.Log($"Renamed Config Extensions", LogLevel.Info, false); } catch (Exception ex) { app.Logger.Log($"An Error Occured While trying to rename files: {ex}", LogLevel.Error, true); } }
/// <summary> /// Creates a class containing strongly typed resources of all resource keys /// in all global resource ResX files. A single class file with multiple classes /// is created. /// /// The extension of the output file determines whether VB or CS is generated /// </summary> /// <param name="Namespace"></param> /// <param name="FileName">Output file name for the generated class. .cs and .vb generate appropriate languages</param> /// <returns>Generated class as a string</returns> public string CreateClassFromFromAllGlobalResXResources(string Namespace, string FileName) { if (!this.WebPhysicalPath.EndsWith("\\")) { this.WebPhysicalPath += "\\"; } bool IsVb = this.IsFileVb(FileName); string ResPath = WebPhysicalPath + "app_globalresources\\"; string[] Files = Directory.GetFiles(ResPath, "*.resx"); StringBuilder sbClasses = new StringBuilder(); foreach (string CurFile in Files) { string file = CurFile.ToLower(); string[] tokens = Path.GetFileName(file).Split('.'); // *** If there's more than two parts is a culture specific file // *** We're only interested in the invariant culture if (tokens.Length > 2) { continue; } // *** ResName: admin/default.aspx or default.aspx or resources (global or assembly resources) string ResName = Path.GetFileNameWithoutExtension(tokens[0]); ResName = ResName.Replace(".", "_"); ResName = CultureInfo.InvariantCulture.TextInfo.ToTitleCase(ResName); string Class = this.CreateClassFromResXResource(file, Namespace, ResName, null); sbClasses.Append(Class); } string Output = this.CreateNameSpaceWrapper(Namespace, IsVb, sbClasses.ToString()); File.WriteAllText(FileName, Output); return(Output); }
/// <summary> /// Imports all resources from a given directory. This method works for any resources. /// /// When using LocalResources, make sure to provide an app relative path as the second /// parameter if the resources live in non root folder. So if you have resources in off /// an Admin folder use "admin/" as the parameter. Otherwise for web root resources or /// global or assembly level assemblies pass string.Empty or null. /// </summary> /// <param name="path">Physical Path for the Resources</param> /// <param name="WebRelativePath">Optional - relative path prefix for Web App_LocalResources (ie. admin/)</param> /// <returns></returns> public bool ImportDirectoryResources(string path, string WebRelativePath) { if (string.IsNullOrEmpty(WebRelativePath)) { WebRelativePath = ""; } string[] Files = Directory.GetFiles(path, "*.resx"); foreach (string CurFile in Files) { string file = CurFile.ToLower(); string[] tokens = file.Replace(".resx", "").Split('.'); // *** ResName: admin/default.aspx or default.aspx or resources (global or assembly resources) string LocaleId = ""; string ResName = WebRelativePath + Path.GetFileNameWithoutExtension(tokens[0]); if (tokens.Length > 1) { string Extension = tokens[1]; if ("aspx|ascx|master|sitemap|".Contains(Extension + "|")) { ResName += "." + Extension; } else { LocaleId = Extension; } } if (tokens.Length > 2) { LocaleId = tokens[2]; } this.ImportResourceFile(file, ResName, LocaleId); } return(true); }
public void CleanAndRotateLogsFolder() { if (this.LastLogRotateCheckTimeUTC.DayOfYear == DateTime.UtcNow.DayOfYear) { return; } try { //filename_2015-08-05_13_08_46_(info)_[info] string Folder = Path.GetDirectoryName(this.LogFile); string Ext = Path.GetExtension(this.LogFile); string[] files = Directory.GetFiles(Folder, "*" + Ext); int DelCnt = 0; int RenCnt = 0; foreach (string CurFile in files) { FileInfo fi = new FileInfo(CurFile); DateTime FileNameDate = Global.GetTimeFromFileName(CurFile); if (!FileNameDate.Equals(DateTime.MinValue) && (fi.LastWriteTimeUtc < DateTime.UtcNow.AddDays(-this.MaxLogFileAgeDays))) { DelCnt = DelCnt + 1; fi.Delete(); } else if (FileNameDate.Equals(DateTime.MinValue) && (CurFile.ToLower() == this.LogFile.ToLower())) //this is the main log filename if it doesnt have a date in it. { if ((this.MaxLogSize > 0 && fi.Length >= this.MaxLogSize) || (DateTime.UtcNow.DayOfYear != fi.LastWriteTimeUtc.DayOfYear)) { Console.WriteLine("LogWriter.New: Renaming log file because size or age: Size: " + fi.Length + ", Max: " + this.MaxLogSize + "..."); string NewFileName = Path.GetFileNameWithoutExtension(CurFile); NewFileName = NewFileName + "_" + fi.LastWriteTimeUtc.ToString("s").Replace(":", "_").Replace("T", "_"); //& "_{UTC}" NewFileName = Folder + "\\" + NewFileName + Ext; try { if (File.Exists(NewFileName)) { File.Delete(NewFileName); } fi.MoveTo(NewFileName); RenCnt = RenCnt + 1; } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } } } } if (DelCnt > 0) { Console.WriteLine("Deleted " + DelCnt + " log files older than " + this.MaxLogFileAgeDays + " days old in " + Folder); } if (RenCnt > 0) { Console.WriteLine("Renamed " + RenCnt + " log files in " + Folder); } } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } finally { this.LastLogRotateCheckTimeUTC = DateTime.UtcNow; } }