internal void AddText(WordFile textword) { if (words.ContainsKey(textword.Text)) { Console.WriteLine("text already exist"); } words.Add(textword.Text, Text.Split(' ').Length); }
public override bool Equals(object obj) { WordFile otherFile = obj as WordFile; if (otherFile == null) { return(false); } return(otherFile.AllFileText == this.AllFileText); }
public static WordFile operator +(WordFile w1, WordFile w2) { int res = w1.FilePath.CompareTo(w2.FilePath); string newPath = (res >= 0? w1.FilePath : w2.FilePath) + ".mrg"; bool newIsReadonly = (res >= 0 ? w1.IsReadonly : w2.IsReadonly); bool newIsArchive = (res >= 0 ? w1.IsArchive : w2.IsArchive); WordFile wf = new WordFile(newPath, w1.Size + w2.Size, newIsReadonly, newIsArchive, w1.FileContents + w2.FileContents); return(wf); }
public static WordFile operator +(WordFile p1, WordFile p2) // 11 { if (p1.FileSize > p2.FileSize) { string newpath = (p1.filePath + ".mrg"); WordFile AddedFile = new WordFile(p1.MyText + p2.MyText, newpath, p1.FileSize + p2.FileSize, p1.IsReadOnly, p1.IsZipped); return(AddedFile); } else { string newpath = (p2.filePath + ".mrg"); WordFile AddedFile = new WordFile(p1.MyText + p2.MyText, newpath, p1.FileSize + p2.FileSize, p2.IsReadOnly, p2.IsZipped); return(AddedFile); } }
static void Main(string[] args) { WordFile words = new WordFile("how are you", 4, false, false); words.PrintFile(); Random randomGenerator = new Random(); int[,] colors = new int[2, 8]; for (int i = 0; i < colors.GetLength(0); i++) { for (int j = 0; j < colors.GetLength(1); j++) { colors[i, j] = randomGenerator.Next(0, 4); } } ImageFile imageFile = new ImageFile(colors, 4, false, false); imageFile.PrintFile(); Console.ReadLine(); }
public static WordFile operator +(WordFile wf1, WordFile wf2) { WordFile bigger = (wf1.FileSize > wf2.FileSize) ? wf1 : wf2; return(new WordFile(wf1.AllFileText + wf2.AllFileText, bigger.filePath + ".mrg", bigger.FileSize, bigger.IsReadOnly, bigger.IsArchive)); }
public override bool Equals(object obj) //10 { WordFile eqfile = obj as WordFile; return(this == eqfile); }
static void Main(string[] args) { WordFile wf = new WordFile("C:\\temp\\1.doc", 10000, true, false, "I Love .Net I Love .Net I Love .Net I I Love .Net I Love .Net I Love .Net I Love C++"); wf.PrintFile(); Console.WriteLine($"NumberOfWords: {wf.NumberOfWords}"); Console.WriteLine($"NumberOfPages {wf.NumberOfPages}"); Console.WriteLine(wf.Indexator(7)); int[,] matrix = new int[4, 4]; int z = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { matrix[i, j] = z + 1; z++; } } ImageFile imf = new ImageFile("C:\\temp\\2.jpg", 10000, true, false, matrix); ImageFile imf1 = new ImageFile("C:\\temp\\2.jpg", 10000, true, false, matrix); imf.PrintFile(); //int myMalwareSize = Convert.ToInt32(ConfigurationManager.AppSettings["MalwareSize"]); //Console.WriteLine($"myMalwareSize: {VirusScanner.MyMalwareSize}"); try { WordFile wf2 = new WordFile("C:\\temp\\3.doc", -1, true, false, "aaa"); } catch (InfectedFileDetectedException ex) { Console.WriteLine("InfectedFileDetectedException in file: " + ex.Message); } WordFile wf4 = new WordFile("C:\\temp\\4.doc", 1000, true, false, "I Love .Net "); WordFile wf5 = new WordFile("C:\\temp\\2.doc", 800, true, false, "I Love .Net "); WordFile wf6 = new WordFile("C:\\temp\\2.doc", 800, true, false, "I Love .Net and C++ "); Console.WriteLine("******Print ALL List****** "); foreach (string mfs in MyFile.Paths) { Console.WriteLine(mfs); } new List <string>(); List <MyFile> ListMyFile = new List <MyFile>(); ListMyFile.Add(wf); ListMyFile.Add(wf4); ListMyFile.Add(wf5); Console.WriteLine("******Print List without sort*************"); PrintList(ListMyFile); //Print Sort List(default) Console.WriteLine("******Print Sort List(default)*************"); ListMyFile.Sort(); PrintList(ListMyFile); //Print Sort List by Path Console.WriteLine("******Print Sort List by Path*************"); FilePathCompare fpc = new FilePathCompare(); ListMyFile.Sort(fpc); PrintList(ListMyFile); bool res = (wf4 == wf5); Console.WriteLine($"(Word file wf4 == Word file wf5) result ={res}"); res = (imf == imf1); Console.WriteLine($"(Image file imf == Image file imf1) result ={res}"); WordFile wf7 = wf4 + wf6; wf7.PrintFile(); Console.WriteLine(wf.GetSpecipicWorsCount("Love")); Console.ReadLine(); }
public static WordFile operator +(WordFile wordfile1, WordFile wordfile2) { WordFile bigger = (wordfile1.FileSize > wordfile2.FileSize) ? wordfile1 : wordfile2; return(new WordFile(wordfile1.Text + wordfile2.Text, bigger.FilePath + ".mrg", wordfile1.FileSize + wordfile2.FileSize, bigger.IsReadOnly, bigger.IsArchiveFile)); }