Example #1
0
        public FileUploadDialog(Xbox xbox, string destinationDirectoryName, params LocalObject[] objects) : this()
        {
            //Setup
            Xbox                       = xbox ?? throw new ArgumentNullException(nameof(xbox));
            m_LocalObjects             = objects ?? throw new ArgumentNullException(nameof(objects));
            m_DestinationDirectoryName = destinationDirectoryName;

            //Connect
            xbox.Connect();

            //Loop
            foreach (LocalObject localObject in objects.Where(o => o.IsDirectory))
            {
                foreach (string directory in localObject.NestedDirectories)
                {
                    //Get info
                    DirectoryInfo info       = new DirectoryInfo(directory);
                    string        targetPath = GetRemoteName(m_DestinationDirectoryName, localObject.Root, directory);

                    //Make directory
                    if (xbox.MakeDirectory(targetPath))
                    {
                        xbox.SetAttributes(targetPath, info.CreationTime, info.LastWriteTime, info.Attributes);
                    }
                }
            }

            //Disconnect
            xbox.Disconnect();

            //Get file count
            m_FileCount = objects.Count(o => o.IsFile) + objects.SelectMany(o => o.NestedFiles).Count();

            //Setup
            xbox.UploadFileCompleted   += Xbox_UploadFileCompleted;
            xbox.UploadProgressChanged += Xbox_UploadProgressChanged;
        }