コード例 #1
0
 private void DeleteDownLoad(DownListInfo d)
 {
     if (d == null)
     {
         return;
     }
     if (d.type == "文件夹")
     {
         if (System.IO.Directory.Exists(d.filename))
         {
             Delete_Directory(d.filename);
         }
     }
     else
     {
         if (System.IO.File.Exists(d.filename))
         {
             FileInfo f = new FileInfo(d.filename);
             f.Delete();
         }
     }
     if (System.IO.File.Exists(d.filename + ".dat"))
     {
         FileInfo f1 = new FileInfo(d.filename + ".dat");
         f1.Delete();
     }
     for (int i = d.ID; i < GarbageInfo.Count; i++)
     {
         GarbageInfo[i].ID = i;
     }
 }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: amos402/ShareWare
 private void SelectedItem(object sender, SelectionChangedEventArgs e)
 {
     if (e.RoutedEvent.Name == "SelectionChanged")
     {
         ListView item = sender as ListView;
         if (item.DataContext != null)
         {
             DownListInfo model = item.SelectedItem as DownListInfo;
             _mainVM.Down_list_Selete = model;
         }
     }
 }
コード例 #3
0
        private void CreatDowndLoadThread(object p)
        {
            FileInfoDataList SeleteInfo1 = (FileInfoDataList)p;

            if (SeleteInfo1 == null)
            {
                return;
            }
            #region MyRegion
            //if (SeleteInfo1.Hash.Length < 36)
            //{
            //    MessageBox.Show("根目录不能下载");
            //    return;
            //}
            #endregion

            if (SeleteInfo1.IsFolder == true)
            {
                MessageBox.Show("根目录不能下载");
                return;
            }
            Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, (ThreadStart) delegate
            {
                DownLoad d = new DownLoad();
                LoadInfo l = new LoadInfo();
                //l.name = @"DriverGenius2012";
                //l.type = "文件夹";
                d.RootDirectory = CurrentDownloadPath + @"\";
                l.name          = SeleteInfo1.Name;
                if (SeleteInfo1.Size == null)
                {
                    l.size = 0;
                }
                else
                {
                    l.size = (long)SeleteInfo1.Size;
                }
                l.type          = SeleteInfo1.Type;
                DownListInfo sm = d.CreatDownLoad(l);
                if (sm == null)
                {
                    return;
                }
                sm.ID    = d.ID = DownInfo.Count;
                sm.State = "下载";
                sm.Hash  = SeleteInfo.Hash;
                DownInfo.Add(sm);
                Down_d.Add(d);
                for (int i = 0; i < Down_d.Count; i++)
                {
                    Down_d[i].Maxseepd = Limit_DownLoad_Speed;
                    Down_d[i].Sum      = Down_d.Count;
                }
                d.Percentage += Refresh;
                //if (ShowSharefile == null)
                {
                    Task <int> task = _client.DownloadRequestAsync(SeleteInfo.Hash, d.Port);
                    task.ContinueWith(T =>
                    {
                    });
                }
                //else ShowSharefile.SendDirectoryName(@":\" + Directory + @"\" + l.name);
                Serialization(@"./config/ImportDownLoadInfo", DownInfo);
            });
        }