Esempio n. 1
0
 private static bool CheckFileSize(string fileSpecA, string fileSpecB)
 {
     Debug.Assert(!string.IsNullOrEmpty(fileSpecA));
     Debug.Assert(!string.IsNullOrEmpty(fileSpecB));
     IO.FileInfo ofi = new System.IO.FileInfo(fileSpecA);
     IO.FileInfo nfi = new System.IO.FileInfo(fileSpecB);
     return(nfi.Length == ofi.Length);
 }
Esempio n. 2
0
            public TestFile(string path)
            {
                var fileInfo = new System.IO.FileInfo(path);

                FullPath   = path;
                Name       = fileInfo.Name;
                LastUpdate = fileInfo.LastWriteTime;
            }
Esempio n. 3
0
        public static void SimpleUpload(string path)
        {
            var file = new System.IO.FileInfo(path);

            RestRequest request = new RestRequest("upload/drive/v3", Method.POST);

            request.AddQueryParameter("uploadType", "media");
            request.AddHeader("Authorization", "Bearer " + accessToken);
            //request.AddHeader("Content-Type", MimeTypeMap.GetMimeType(file.Extension));
            request.AddFile("file", path, MimeTypeMap.GetMimeType(file.Extension));

            var response = client.Execute(request);

            Console.WriteLine(response.Content);
        }
Esempio n. 4
0
        public void TorrentCommands_OpenFile(object sender, ExecutedRoutedEventArgs e)
        {
            Aga.Controls.Tree.TreeNode item = files_tree.SelectedItem as Aga.Controls.Tree.TreeNode;

            if (item != null)
            {
                FileInfo fi = item.Tag as FileInfo;
                if (fi != null)
                {
                    System.IO.FileInfo fifo = new System.IO.FileInfo(fi.FullPath);

                    if (fifo.Exists)
                    {
                        string[] dangerous_file_types = { ".exe", ".scr", ".pif", ".js", ".com", ".bat", ".cmd", ".vbs", ".hta" };

                        if (dangerous_file_types.Contains(fifo.Extension.ToLower()))
                        {
                            if (MessageBox.Show(string.Format(@"Opening files downloaded from the Internet may result in harm to your computer or your data."
                                                              + " Are you sure that you want to open {0}?", fifo.Name),
                                                "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                            {
                                Process.Start(fifo.FullName);
                            }
                        }
                        else
                        {
                            Process.Start(fifo.FullName);
                        }
                    }
                    else
                    {
                        MessageBox.Show("File doesn't exist", "Error");
                    }
                }
                else
                {
                    DirectoryKey dk = item.Tag as DirectoryKey;
                    if (dk != null)
                    {
                        string partial_path = this.GetDirectoryKeyRelativePath(item);
                        string full_path    = System.IO.Path.Combine(dk.OwnerTorrent.SavePath, partial_path);
                        System.IO.Directory.CreateDirectory(full_path);
                        Process.Start("explorer.exe", string.Format("\"{0}\"", full_path));
                    }
                }
            }
        }
Esempio n. 5
0
 private static Guid StoreIndexBackupToDb(string backupFilePath)
 {
     try
     {
         var length = new System.IO.FileInfo(backupFilePath).Length;
         Progress.StartStoreIndexBackupToDb(length);
         var id = ContentRepository.Storage.DataBackingStore.StoreIndexBackupToDb(backupFilePath, Progress);
         Progress.FinishStoreIndexBackupToDb();
         return(id);
     }
     catch (Exception e)
     {
         if (DistributedNotifyProgress)
         {
             new IndexBackupProgressMessage(IndexBackupProgressType.Error, e.Message + e.StackTrace, 1, 1);
         }
         throw;
     }
 }
Esempio n. 6
0
 private static bool CheckFileSize(string fileSpecA, string fileSpecB)
 {
     Debug.Assert(!string.IsNullOrEmpty(fileSpecA));
     Debug.Assert(!string.IsNullOrEmpty(fileSpecB));
     IO.FileInfo ofi = new System.IO.FileInfo(fileSpecA);
     IO.FileInfo nfi = new System.IO.FileInfo(fileSpecB);
     return (nfi.Length == ofi.Length);
 }
Esempio n. 7
0
 private static Guid StoreIndexBackupToDb(string backupFilePath)
 {
     try
     {
         var length = new System.IO.FileInfo(backupFilePath).Length;
         Progress.StartStoreIndexBackupToDb(length);
         var id = SenseNet.ContentRepository.Storage.DataBackingStore.StoreIndexBackupToDb(backupFilePath, Progress);
         Progress.FinishStoreIndexBackupToDb();
         return id;
     }
     catch (Exception e)
     {
         if (DistributedNotifyProgress)
             new IndexBackupProgressMessage(IndexBackupProgressType.Error, e.Message + e.StackTrace, 1, 1);
         throw;
     }
 }
Esempio n. 8
0
 private bool CheckFileSize()
 {
     IO.FileInfo ofi = new System.IO.FileInfo(OriginalAssembly.ItemSpec);
     IO.FileInfo nfi = new System.IO.FileInfo(NewAssembly.ItemSpec);
     return(nfi.Length == ofi.Length);
 }