コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cesta"></param>
        /// <param name="struktura"></param>
        public async static Task VytvorSoubory(string cesta, Mega_status MS, int i)
        {
            cesta = cesta.Replace('/', '\\');
            string slozka = cesta.Remove(cesta.LastIndexOf("\\"));

            slozka = slozka.Substring(slozka.LastIndexOf("\\") + 1);
            if (slozka == "fotky")
            {
                slozka = "Fotky";
            }
            var nodes = client.GetNodes();


            INode slozka_cpy = nodes.FirstOrDefault(n => n.Name == slozka);
            //  client.UploadFile(cesta, slozka_cpy);


            Progress <double> progress = new Progress <double>();

            progress.ProgressChanged += (s, progressValue) =>
            {
                //Update the UI (or whatever) with the progressValue
                MS.dataGridView2.Rows[i].Cells[1].Value = (int)progressValue;
            };


            INode myFile = await client.UploadFileAsync(cesta, slozka_cpy, progress, uploadCancellationTokenSource.Token);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: xkolm036/Foto
        private void button_mega_Click(object sender, EventArgs e)
        {
            button_mega.Text    = "Loading";
            button_mega.Enabled = false;

            List <string> diffSlozky  = new List <string>();
            List <string> diffSoubory = new List <string>();
            List <string> zdrojlist;
            List <string> cillist = new List <string>();

            Task t = Task.Run(() =>
            {
                FileManager.DirSearch(zdroj);
                zdrojlist = new List <string>(FileManager.Slozky);

                foreach (string s in FileManager.Soubory)
                {
                    zdrojlist.Add(s);
                }

                FileManager.clear();


                Mega.pripoj();
                if (checkBox_list.Checked == false)
                {
                    cillist = Mega.VratStruktura();
                }

                //Pridat z nacteneho listu
                foreach (string s in ListFiles)
                {
                    if (!cillist.Contains(s))
                    {
                        cillist.Add(s);
                    }
                }

                foreach (string s in ListDirs)
                {
                    if (!cillist.Contains(s))
                    {
                        cillist.Add(s);
                    }
                }


                FileManager.difflist(zdrojlist, cillist, ref diffSlozky, ref diffSoubory);
            }
                              );
            var awaiter = t.GetAwaiter();

            awaiter.OnCompleted(() =>
            {
                button_mega.Text    = "Zálohovat na mega";
                button_mega.Enabled = true;
                Form mega           = new Mega_status(diffSlozky, diffSoubory, cillist);
                mega.Show();
            }
                                );
        }