コード例 #1
0
    public void Download(string path, CancellableProgress progress, Action <Stream> success, Action <Exception> failure)
    {
        FileStream stream = default(FileStream);
        Exception  e      = default(Exception);

        ThreadPool.QueueUserWorkItem(delegate
        {
            try
            {
                InitializeFilesystemAccess();
                string path2 = ToInternalPath(path);
                stream       = new FileStream(path2, FileMode.Open, FileAccess.Read, FileShare.Read);
                Dispatcher.Dispatch(delegate
                {
                    success(stream);
                });
            }
            catch (Exception ex)
            {
                e = ex;
                Dispatcher.Dispatch(delegate
                {
                    failure(e);
                });
            }
        });
    }
コード例 #2
0
    public void List(string path, CancellableProgress progress, Action <ExternalContentEntry> success, Action <Exception> failure)
    {
        ExternalContentEntry entry = default(ExternalContentEntry);
        Exception            e     = default(Exception);

        ThreadPool.QueueUserWorkItem(delegate
        {
            try
            {
                InitializeFilesystemAccess();
                string internalPath = ToInternalPath(path);
                entry = GetDirectoryEntry(internalPath, scanContents: true);
                Dispatcher.Dispatch(delegate
                {
                    success(entry);
                });
            }
            catch (Exception ex)
            {
                e = ex;
                Dispatcher.Dispatch(delegate
                {
                    failure(e);
                });
            }
        });
    }
コード例 #3
0
    public void Upload(string path, Stream stream, CancellableProgress progress, Action <string> success, Action <Exception> failure)
    {
        Exception e = default(Exception);

        ThreadPool.QueueUserWorkItem(delegate
        {
            try
            {
                InitializeFilesystemAccess();
                string uniquePath = GetUniquePath(ToInternalPath(path));
                string po         = uniquePath;
                if (po.StartsWith("android:"))
                {
                    po = Storage.GetSystemPath(po);
                }
                string pp = Storage.GetDirectoryName(po);
                Directory.CreateDirectory(pp);
                using (FileStream destination = new FileStream(po, FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    stream.CopyTo(destination);
                }
                Dispatcher.Dispatch(delegate
                {
                    success(null);
                });
            }
            catch (Exception ex)
            {
                e = ex;
                Dispatcher.Dispatch(delegate
                {
                    failure(e);
                });
            }
        });
    }
コード例 #4
0
 public void Login(CancellableProgress progress, Action success, Action <Exception> failure)
 {
     failure(new NotSupportedException());
 }
コード例 #5
0
 public void Link(string path, CancellableProgress progress, Action <string> success, Action <Exception> failure)
 {
     failure(new NotSupportedException());
 }