コード例 #1
0
 ///<summary>The first parameter, 'sourceFileName', must be a file that exists. Sychronous for cloud storage.</summary>
 public static void Copy(string sourceFileName, string destinationFileName, FileAtoZSourceDestination sourceDestination, bool isFolder = false,
                         bool doOverwrite = false)
 {
     if (CloudStorage.IsCloudStorage)
     {
         sourceFileName      = CloudStorage.PathTidy(sourceFileName);
         destinationFileName = CloudStorage.PathTidy(destinationFileName);
         OpenDentalCloud.TaskState state;
         if (sourceDestination == FileAtoZSourceDestination.AtoZToAtoZ)
         {
             state = CloudStorage.Copy(sourceFileName, destinationFileName);
         }
         else if (sourceDestination == FileAtoZSourceDestination.LocalToAtoZ)
         {
             state = CloudStorage.Upload(Path.GetDirectoryName(destinationFileName), Path.GetFileName(destinationFileName),
                                         File.ReadAllBytes(sourceFileName));
         }
         else if (sourceDestination == FileAtoZSourceDestination.AtoZToLocal)
         {
             state = CloudStorage.Download(Path.GetDirectoryName(sourceFileName), Path.GetFileName(sourceFileName));
         }
         else
         {
             throw new Exception("Unsupported " + nameof(FileAtoZSourceDestination) + ": " + sourceDestination);
         }
         if (sourceDestination == FileAtoZSourceDestination.AtoZToLocal)
         {
             File.WriteAllBytes(destinationFileName, ((OpenDentalCloud.Core.TaskStateDownload)state).FileContent);
         }
     }
     else              //Not cloud
     {
         File.Copy(sourceFileName, destinationFileName, doOverwrite);
     }
 }
コード例 #2
0
ファイル: FileAtoZ.cs プロジェクト: kjb7749/testImport
 ///<summary>The first parameter, 'sourceFileName', must be a file that exists.</summary>
 public static void Copy(string sourceFileName, string destinationFileName, FileAtoZSourceDestination sourceDestination,
                         string uploadMessage = "Copying file...", bool isFolder = false)
 {
     if (CloudStorage.IsCloudStorage)
     {
         sourceFileName      = CloudStorage.PathTidy(sourceFileName);
         destinationFileName = CloudStorage.PathTidy(destinationFileName);
         FormProgress FormP = CreateFormProgress(uploadMessage, isFolder);
         OpenDentalCloud.TaskState state;
         if (sourceDestination == FileAtoZSourceDestination.AtoZToAtoZ)
         {
             state = CloudStorage.CopyAsync(sourceFileName, destinationFileName, new OpenDentalCloud.ProgressHandler(FormP.OnProgress));
         }
         else if (sourceDestination == FileAtoZSourceDestination.LocalToAtoZ)
         {
             state = CloudStorage.UploadAsync(Path.GetDirectoryName(destinationFileName), Path.GetFileName(destinationFileName),
                                              File.ReadAllBytes(sourceFileName), new OpenDentalCloud.ProgressHandler(FormP.OnProgress));
         }
         else if (sourceDestination == FileAtoZSourceDestination.AtoZToLocal)
         {
             state = CloudStorage.DownloadAsync(Path.GetDirectoryName(sourceFileName), Path.GetFileName(sourceFileName),
                                                new OpenDentalCloud.ProgressHandler(FormP.OnProgress));
         }
         else
         {
             throw new Exception("Unsupported " + nameof(FileAtoZSourceDestination) + ": " + sourceDestination);
         }
         FormP.ShowDialog();
         if (FormP.DialogResult == DialogResult.Cancel)
         {
             state.DoCancel = true;
             return;
         }
         if (sourceDestination == FileAtoZSourceDestination.AtoZToLocal)
         {
             File.WriteAllBytes(destinationFileName, ((OpenDentalCloud.Core.TaskStateDownload)state).FileContent);
         }
     }
     else              //Not cloud
     {
         File.Copy(sourceFileName, destinationFileName);
     }
 }