Ejemplo n.º 1
0
        public FileInfoContract NewFileItem(DirectoryInfoContract parent, string name, Stream content, ProgressProxy progress)
        {
            try {
                if (content != null && !string.IsNullOrEmpty(encryptionKey))
                {
                    content = content.Encrypt(encryptionKey);
                }

                ProgressProxy.ProgressFunc <FileInfoContract> func = p => gateway.NewFileItemAsync(rootName, parent.Id, name, content, p);
                return(ProgressProxy.TraceProgressOn(func, progress));
            } catch (AggregateException ex) when(ex.InnerExceptions.Count == 1)
            {
                throw ex.InnerExceptions[0];
            } finally {
                InvalidateDrive();
            }
        }
Ejemplo n.º 2
0
        public void SetContent(FileInfoContract target, Stream content, ProgressProxy progress)
        {
            try {
                if (!string.IsNullOrEmpty(encryptionKey))
                {
                    content = content.Encrypt(encryptionKey);
                }

                Func <FileSystemInfoLocator>      locator = () => new FileSystemInfoLocator(target);
                ProgressProxy.ProgressFunc <bool> func    = p => gateway.SetContentAsync(rootName, target.Id, content, p, locator);
                ProgressProxy.TraceProgressOn(func, progress);
                target.Size = content.Length;
            } catch (AggregateException ex) when(ex.InnerExceptions.Count == 1)
            {
                throw ex.InnerExceptions[0];
            } finally {
                InvalidateDrive();
            }
        }