Esempio n. 1
0
        public static async Task CopyFiles(scFilesSystemEntries files, Action <string, Constants.Status, long, long, long> progressCallback)
        {
            Int64 iNbTotal   = files.getTotalSize();
            Int64 iNbCurrent = 0;

            foreach (scDir dir in files.DirList)
            {
                if (!Directory.Exists(dir.ToName))
                {
                    Directory.CreateDirectory(dir.ToName);
                }
            }
            //All dir created to destination
            foreach (scFile file in files.FileList)
            {
                try
                {
                    await CopyData(file, (fi, status, filesize) => progressCallback(fi, status, filesize, iNbCurrent, iNbTotal));

                    iNbCurrent += file.FileSize;
                }
                catch (Exception)
                {
                    //TODO: Add Log or some error management
                    throw;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// generate a list of fileSystemEntry (dirs and/or filse) contained in a dir to a destination Dir
        /// </summary>
        /// <param name="sOriginDir">Origin Directory to parse</param>
        /// <param name="sDestDir">Destination Directory</param>
        /// <returns>Entries in given origin directory</returns>
        public static scFilesSystemEntries generateEntryByDir(string sOriginDir, string sDestDir)
        {
            scFilesSystemEntries files;
            List <string>        myFileSystemEntry = Directory.GetFileSystemEntries(sOriginDir, "*", SearchOption.AllDirectories).ToList <string>();

            files = new scFilesSystemEntries(myFileSystemEntry, sOriginDir, sDestDir, Constants.Action.Copy);

            return(files);
        }
Esempio n. 3
0
        /// <summary>
        /// generate a list of fileSystemEntry (dirs and/or filse) to a destination Dir
        /// </summary>
        /// <param name="sListFSI">list of FileSystemEntry</param>
        /// <param name="sDestDir">Destination Directory</param>
        /// <returns>Entries in given list</returns>
        public static scFilesSystemEntries generateEntryByList(List <string> sListFSI, string sDestDir)
        {
            scFilesSystemEntries files = new scFilesSystemEntries();

            foreach (string fsi in sListFSI)
            {
                FileAttributes attr = File.GetAttributes(fsi);

                //detect whether its a directory or file
                if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
                {
                    List <string> myFileSystemEntry = Directory.GetFileSystemEntries(fsi, "*", SearchOption.AllDirectories).ToList <string>();
                    myFileSystemEntry.Add(new DirectoryInfo(fsi).FullName);
                    files.add(new scFilesSystemEntries(myFileSystemEntry, getParentDir(fsi), sDestDir, Constants.Action.Copy));
                }
                else
                {
                    files.add(fsi, getParentDir(fsi), sDestDir, Constants.Action.Copy);
                }
            }

            return(files);
        }
Esempio n. 4
0
 public void add(scFilesSystemEntries scEntries)
 {
     this._lfDirs.AddRange(scEntries.DirList);
     this._lfFiles.AddRange(scEntries.FileList);
 }