/// <summary> /// Creates a new file object and add it to list, if the file have already existed it will be updated. /// </summary> /// <param name="Name">The name of the file.</param> /// <param name="Size">The size of the file.</param> /// <param name="SHA1">The SHA1-ID of the file.</param> /// <param name="PeerIP">One PeerID only.</param> /// <param name="PeerID"></param> public static void CreateAndAddFile(string Name, int Size, string SHA1, string PeerIP, string PeerID) { FilesFoundList.File file = new FilesFoundList.File(); file.Name = Name; file.Size = Size; file.SHA1 = SHA1; file.AddPeer(PeerIP, PeerID); FilesFoundList.AddFile(file); }
/// <summary> /// Creates a new file in the list or, if it already exists, update it. /// </summary> /// <param name="File">File object.</param> public static void AddFile(FilesFoundList.File File) { for (int i = 0; i < m_filesList.Count; i++) { try { if (m_filesList[i].SHA1 == File.SHA1 && m_filesList[i].Name == File.Name) { m_filesList[i] = UpdateFile(m_filesList[i], File); return; } } catch { } } // add the filw in the list m_filesList.Add(File); }