示例#1
0
文件: Main.cs 项目: BekaB/PeerToPeer
 private void Form1_Load(object sender, EventArgs e)
 {
     manager = new Manager();
     manager.FilePartDownloaded += manager_FilePartDownloaded;
     downloadingFiles = new List<DownloadFileDisplay>();
     downloadingData = new List<List<Tuple<Manager.DownloadParameter,byte[]>>>();
     dataGridViewMain.DataSource = downloadingFiles;
 }
示例#2
0
文件: Main.cs 项目: BekaB/PeerToPeer
        private void SaveFile(Manager.DownloadParameter parameter)
        {
            CheckForIllegalCrossThreadCalls = false;

            List<Tuple<Manager.DownloadParameter, Byte[]>> prevData = downloadingData.FirstOrDefault(d =>
                d.First().Item1.File.FileName == parameter.File.FileName &&
                d.First().Item1.File.FileHash == parameter.File.FileHash);

            downloadingData.RemoveAll(d =>
                d.First().Item1.File.FileName == parameter.File.FileName &&
                d.First().Item1.File.FileHash == parameter.File.FileHash);

            var lst = prevData.OrderBy(x => x.Item1.Part).ToList();
            var bytes = new List<byte>();

            for (int i = 0; i < lst.Count; i++)
            {
                bytes.AddRange(lst[i].Item2);
            }

            string filePath = ClassLibrary.Config.SharedFolder + @"\" + parameter.File.FileName;

            System.IO.File.WriteAllBytes(filePath, bytes.ToArray());

            MessageBox.Show(this, String.Format("The download of file '{0}' is completed!", parameter.File.FileName),
                "Client", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
示例#3
0
 public SharedFileManager()
 {
     InitializeComponent();
     manager = new Manager();
     dataGridViewFManager.DataSource = LoadFiles();
 }