public static void Log(Exception exception, string content = "") { var a = content ?? ""; var log = "Time: " + DateTime.Now + "\n" + "Message: " + exception.Message + "\n" + "Stack Trace: " + exception.StackTrace + "\n" + "Exception Type: " + exception.GetType().Name + "\n" + "" + ((content == string.Empty) ? content : "\n"); fileOperator.AppendFile(log); }
public bool OnContextMenuCommand(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags) { if (commandId == CefMenuCommand.AddToDictionary) { Entry entry = new Entry(); try { var temp = File.ReadAllText(FilePaths.TemporaryFiles.LastWord); var index = temp.IndexOf('/'); entry.Word = temp.Substring(0, index); // "good/güzel" lenght == 9 , temp.IndexOf('/') == 5 entry.Meaning = temp.Substring(index + 1, temp.Length - 1 - index); } catch (DirectoryNotFoundException e) { MessageBox.Show("Eklenecek Dizin Bulunamadı \n" + "Hata Mesajı:" + e.Message); return(false); } catch (FileNotFoundException) { MessageBox.Show("Bu Sayfayı Ekleyemezsin"); return(false); } var userDictionary = new JsonOperator(FilePaths.PermanentFiles.UserDictionary); var words = userDictionary.LoadFile(); if (words.All(x => x.Word != entry.Word)) { entry.Date = DateTime.Now.ToString(); userDictionary.AppendFile(entry.ToString()); } else { MessageBox.Show("Kelime Zaten Sözlüğe Eklenmmiş!"); } return(true); } return(false); }