Beispiel #1
0
        public string DownloadFileToOpen(CloudFile toOpen, Action <long, long> callback)
        {
            try
            {
                var fileName = Path.GetFileName(toOpen?.Uri?.LocalPath?.Replace("/", "\\") ?? "");
                var tmpPath  = Path.GetTempPath();

                string fullTmpPath = Path.Combine(tmpPath, fileName)?.Replace("\\", "/");

                if (File.Exists(fullTmpPath))
                {
                    File.Delete(fullTmpPath);
                }

                using (var fs = new ObservableFileStream(fullTmpPath, FileMode.OpenOrCreate, callback))
                {
                    toOpen?.DownloadToStream(fs);
                }

                return(fullTmpPath);
            } catch (Exception ex)
            {
                return("");
            }
        }
Beispiel #2
0
        public CloudFile CopyLocal(CloudFileDirectory dir, string path, Action <long, long> progressChanged)
        {
            try
            {
                var       fileName = Path.GetFileName(path);
                CloudFile file     = dir?.GetFileReference(fileName);
                if (file != null && file.Exists())
                {
                    throw new Exception("File already exists on server!");
                }

                using (FileStream fs = new ObservableFileStream(path, FileMode.Open, progressChanged))
                {
                    file?.UploadFromStream(fs);
                }

                return(file);
            } catch (Exception ex)
            {
                return(null);
            }
        }