bool HasFileReachMaxSize() { currentFile = new FileInfo(Path.GetFullPath(filePathFull)); var fileSize = AvatarUtils.ConvertToMegabytes(currentFile.Length); var maxSize = Settings.Instance.LogMaxFileSize; return((fileSize > maxSize) ? true : false); }
private void CheckFolderSize() { System.IO.DirectoryInfo di = new DirectoryInfo(filePath); FileInfo[] files = di.GetFiles().OrderBy(p => p.CreationTime).ToArray(); long totalSize = 0; for (int i = 0; i < files.Length; i++) { totalSize += files[i].Length; } print(AvatarUtils.ConvertToMegabytes(totalSize) + " " + Settings.Instance.logMaxFolderSize); if (AvatarUtils.ConvertToMegabytes(totalSize) > Settings.Instance.logMaxFolderSize) { files[0].Delete(); } }