Пример #1
0
        private void OnConnectDeviceCommandExecute(object obj)
        {
            SelectedDevice.Connect();
            ConnectedDevice = SelectedDevice;

            //var functionalCategories = SelectedDevice.FunctionalCategories();
            //foreach (var functionalCategory in functionalCategories)
            //{
            //    var functionalObjects = SelectedDevice.FunctionalObjects(functionalCategory);
            //}

            var fuid = ConnectedDevice.FunctionalUniqueId;
            var root = ConnectedDevice.GetRootDirectory();

            var images = ConnectedDevice.GetContentLocations(ContentType.Image);
            var dirs   = ConnectedDevice.GetDirectories(ConnectedDevice.GetRootDirectory().FullName);

            //var test = ConnectedDevice.GetFiles(@"\\SD-Karte von Transcend\DCIM\Camera");

            if (dirs.Length == 0)
            {
                return;
            }

            var thread = new Thread(
                () =>
            {
                var camPath     = @"\\SD-Karte von Transcend\DCIM\Camera";
                var directories = ConnectedDevice.GetDirectories(camPath);
                var files       = ConnectedDevice.GetFiles(camPath);

                for (int i = 0; i < files.Length; i++)
                {
                    var s        = files[i];
                    var fileName = Path.GetFileName(s);
                    var filePath = Path.Combine(camPath, s);
                    var fi       = ConnectedDevice.GetFileInfo(filePath);

                    try
                    {
                        using (var stream = new MemoryStream())
                        {
                            ConnectedDevice.DownloadFile(s, stream);
                            using (var fs = new FileStream($"C:\\Dev\\#Test\\DownloadedFromG4\\{fileName}", FileMode.Create))
                            {
                                stream.Seek(0, SeekOrigin.Begin);
                                stream.WriteTo(fs);
                            }
                        }
                    }
                    catch (System.Exception e)
                    {
                        throw;
                    }
                }
            });

            thread.Start();


            foreach (var enumerateFileSystemInfo in root.EnumerateFileSystemInfos())
            {
                foreach (var fileSystemEntry in ConnectedDevice.GetFileSystemEntries(enumerateFileSystemInfo.FullName))
                {
                    var path = Path.Combine(enumerateFileSystemInfo.FullName, fileSystemEntry);
                    var fi   = ConnectedDevice.GetFileInfo(path);

                    if (fi.FullName.Contains("DCIM"))
                    {
                        foreach (var dir in fi.Directory.EnumerateDirectories())
                        {
                            if (dir.FullName.Contains("DCIM"))
                            {
                                foreach (var enumerateDirectory in dir.EnumerateDirectories())
                                {
                                    if (enumerateDirectory.FullName.Contains("Camera"))
                                    {
                                        var files = enumerateDirectory.EnumerateFiles();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }