diff --git a/ShareX.HelpersLib/NameParser/NameParser.cs b/ShareX.HelpersLib/NameParser/NameParser.cs index 973178809..777906045 100644 --- a/ShareX.HelpersLib/NameParser/NameParser.cs +++ b/ShareX.HelpersLib/NameParser/NameParser.cs @@ -84,9 +84,9 @@ public string Parse(string pattern) if (WindowText != null) { string windowText = WindowText.Trim().Replace(' ', '_'); - if (MaxTitleLength > 0 && windowText.Length > MaxTitleLength) + if (MaxTitleLength > 0) { - windowText = windowText.Remove(MaxTitleLength); + windowText = windowText.Truncate(MaxTitleLength); } sb.Replace(CodeMenuEntryFilename.t.ToPrefixString(), windowText); } @@ -322,9 +322,9 @@ public string Parse(string pattern) result = Helpers.GetValidURL(result); } - if (MaxNameLength > 0 && result.Length > MaxNameLength) + if (MaxNameLength > 0) { - result = result.Remove(MaxNameLength); + result = result.Truncate(MaxNameLength); } return result; diff --git a/ShareX/ImageInfo.cs b/ShareX/ImageInfo.cs index 9d022ce3d..dc4af9e1f 100644 --- a/ShareX/ImageInfo.cs +++ b/ShareX/ImageInfo.cs @@ -32,8 +32,34 @@ namespace ShareX public class ImageInfo : IDisposable { public Bitmap Image { get; set; } - public string WindowTitle { get; set; } - public string ProcessName { get; set; } + + private string windowTitle; + + public string WindowTitle + { + get + { + return windowTitle; + } + set + { + windowTitle = value.Truncate(255); + } + } + + private string processName; + + public string ProcessName + { + get + { + return processName; + } + set + { + processName = value.Truncate(255); + } + } public ImageInfo() {