Ejemplo n.º 1
0
        //Download button
        private void button3_Click(object sender, EventArgs e)
        {
            ListView.SelectedListViewItemCollection selectedItem = listView2.SelectedItems;

            foreach (ListViewItem item in selectedItem)
            {
                downloadAsync download = new downloadAsync();

                String   fileName  = item.Text.ToString().Split(' ')[0];
                FileInfo fileInfo  = new FileInfo(textBox2.Text + "\\" + fileName);
                Regex    regex     = new Regex(@"\bDBLite\\\b");
                String[] nameSplit = regex.Split(textBox2.Text + "\\" + fileName);
                if (nameSplit[1].Contains("\\"))
                {
                    Regex    regexForBacklash = new Regex(@"\\\b");
                    String[] filenameSplit    = regexForBacklash.Split(nameSplit[1], 2);
                    if (publicFlrOptions.Enabled)
                    {
                        download.download(filenameSplit[0], filenameSplit[1].Replace('\\', '/'), textBox1.Text, emailId, fileInfo.Length.ToString());
                    }
                    else
                    {
                        download.download(emailId, nameSplit[1].Replace('\\', '/'), textBox1.Text, emailId, fileInfo.Length.ToString());
                    }
                }
                else
                {
                    download.download(emailId, nameSplit[1].Replace('\\', '/'), textBox1.Text, emailId, fileInfo.Length.ToString());
                }

                //MessageBox.Show("Download complete");
                listView1.Items.Clear();
                display();
            }
        }
Ejemplo n.º 2
0
        private void updateFile(cloudinfoContainerFile file, string filePath, string containerName, string fileName, cloudinfoContainer container)
        {
            String[] files = Directory.GetFiles(filePath);

            if (getListOfdirs(files).Contains(fileName))
            {
                //check timestamp
                var fileInfo = new FileInfo(filePath + "\\" + fileName);

                //local.compateTo(cloud)
                //string format = "ddd dd MMM h:mm tt yyyy";
                String[] date     = file.timestamp.Split('+');
                DateTime dateTime = Convert.ToDateTime(date[0]);

                //long t = TimeSpan.TryParse(file.timestamp, format,  out dateTime).Ticks;
                int i = fileInfo.LastWriteTimeUtc.CompareTo(dateTime);

                if (i < 0 && new Common().getFileMD5(filePath + "\\" + fileName) != file.md5 && (file.deleted == "False"))
                {
                    //download the cloud file @filePath + "\\" + file.name
                    downloadAsync da = new downloadAsync();
                    da.download(containerName, file.name, filePath, email, file.size);
                }
                else if (i > 0 && new Common().getFileMD5(filePath + "\\" + fileName) != file.md5)
                {
                    if (file.deleted != "False")
                    {
                        //delete the file in the local
                        File.Delete(filePath + "\\" + fileName);
                    }
                    else
                    {
                        //upload the local file filePath + "\\" + file.name
                        Upload upload = new Upload();
                        upload.DocUplaod(containerName, filePath, fileInfo.Length.ToString(), file.name,
                                         new Common().getFileMD5(filePath + "\\" + fileName),
                                         fileInfo.LastWriteTimeUtc.Ticks.ToString(), new Common().getOldHash(container, fileInfo));
                    }
                    //if (result)
                    {
                        //MessageBox.Show("Uploaded Successfully");
                    }
                }
            }
            else
            {
                if (file.deleted == "False")
                {
                    //download the file
                    downloadAsync da = new downloadAsync();
                    da.download(containerName, file.name, filePath, email, file.size);
                }
            }
        }