示例#1
0
        internal static void CopyFile(string source, string destination, bool overwrite, bool compressDestination)
        {
            string tempArchivePath = string.Empty;

            try
            {
                if (compressDestination)
                {
                    string archiveEntryName = Path.GetFileNameWithoutExtension(destination);
                    FileCompressor.Compress(source, archiveEntryName, out tempArchivePath);

                    source = tempArchivePath;
                }

                CopyFileParameters copyParam = new CopyFileParameters()
                {
                    Source      = source,
                    Destination = destination,
                    Overwrite   = true
                };

                Utility.PerformIOWithRetries(
                    CopyFileWorker,
                    (object)copyParam);
            }
            finally
            {
                if (false == string.IsNullOrEmpty(tempArchivePath))
                {
                    Utility.PerformIOWithRetries(
                        () => { FabricFile.Delete(tempArchivePath); });
                }
            }
        }
示例#2
0
        private static void CopyFileWorker(object context)
        {
            CopyFileParameters copyParam = (CopyFileParameters)context;

            FabricFile.Copy(copyParam.Source, copyParam.Destination, copyParam.Overwrite);
        }