Beispiel #1
0
        public override bool CreateFolder(string path, string nameFolder)
        {
            if (ShowDebugrMessages || System.Diagnostics.Debugger.IsAttached)
            {
                Console.WriteLine("--- Creating Folder ---");
            }

            CreateFolderArg           folderArg = new CreateFolderArg(System.IO.Path.Combine(path, nameFolder).Replace('\\', '/'));
            Task <CreateFolderResult> tskFolder = client.Files.CreateFolderV2Async(folderArg);
            CreateFolderResult        folder;
            bool result;

            try
            {
                folder = tskFolder.Result;

                if (ShowDebugrMessages || System.Diagnostics.Debugger.IsAttached)
                {
                    Console.WriteLine("Folder: " + path + " created!");
                }
                result = true;
            }
            catch { result = false; }
            return(result);
        }
Beispiel #2
0
    public async Task CreateFolder(string path)
    {
        try
        {
            if (AccessToken == null)
            {
                throw new Exception("AccessToken not generated !");
            }

            path = CompletePath(path);

            bool exist = await FolderExists(path);

            if (exist)
            {
                return;
            }

            var folderArg = new CreateFolderArg(path);
            await DBClient.Files.CreateFolderAsync(folderArg);

            Console.Write("Folder {0} created successfullly.\n", path);
        }
        catch (Exception e)
        {
            throw e;
        }
    }
Beispiel #3
0
        public async Task <FolderMetadata> CreateFolder(string path)
        {
            var full = await dbx.Users.GetCurrentAccountAsync();

            var folderArg = new CreateFolderArg(path);
            var folder    = await dbx.Files.CreateFolderAsync(folderArg);

            return(folder);
        }
Beispiel #4
0
 public override void CreateDir(FileItem from)
 {
     if (from.Path.EndsWith("/"))
     {
         from.Path = from.Path.Substring(0, from.Path.Length - 1);
     }
     var folderArg = new CreateFolderArg(from.Path);
     var folder    = DBClient.Files.CreateFolderV2Async(folderArg).Result;
 }
Beispiel #5
0
        public async Task <string> CreateFolder()
        {
            using (var dbx = new DropboxClient(token))
            {
                var folderArg = new CreateFolderArg("/Test");
                var result    = await dbx.Files.CreateFolderV2Async(folderArg);

                return(result.Metadata.Name);
            }
        }
        /// <summary>
        /// Creates the specified folder.
        /// </summary>
        /// <remarks>This demonstrates calling an rpc style api in the Files namespace.</remarks>
        /// <param name="path">The path of the folder to create.</param>
        /// <param name="client">The Dropbox client.</param>
        /// <returns>The result from the ListFolderAsync call.</returns>
        private async Task <FolderMetadata> CreateFolder(DropboxClient client, string path)
        {
            Console.WriteLine("--- Creating Folder ---");
            var folderArg = new CreateFolderArg(path);
            var folder    = await client.Files.CreateFolderAsync(folderArg);

            Console.WriteLine("Folder: " + path + " created!");

            return(folder);
        }
Beispiel #7
0
        // Create a foler in dropbox
        public async Task <FolderMetadata> CreateFolder(string path) //DropboxClient client,
        {
            dBoxStatus = GlobalVariables.DropBoxStatus.Creating;
            var folderArg = new CreateFolderArg(path);
            var folder    = await client.Files.CreateFolderV2Async(folderArg);

            Console.WriteLine("Folder: " + path + " created!");
            dBoxStatus = GlobalVariables.DropBoxStatus.Created;

            return(folder.Metadata);
        }
Beispiel #8
0
 public bool CreateFolder(DropboxClient client, string path)
 {
     try
     {
         var folderArg = new CreateFolderArg(path);
         var folder    = client.Files.CreateFolderV2Async(folderArg);
         var result    = folder.Result;
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #9
0
        /*
         * Argument 1 : Name of the folder to be created in dropbox (it will be created in root folder)
         */
        public async Task CreateFolder(string foldername)
        {
            var list = await dropbox_client.Files.ListFolderAsync(string.Empty);

            foreach (var item in list.Entries.Where(i => i.IsFolder))
            {
                if (item.Name.Equals(foldername))
                {
                    Console.WriteLine("Error: folder with name {0} already exists!", foldername);
                    return;
                }
            }
            Dropbox.Api.Files.CreateFolderArg folderArg = new CreateFolderArg("/" + foldername);
            await dropbox_client.Files.CreateFolderAsync(folderArg);
        }
Beispiel #10
0
        private static async Task <FolderMetadata> CreateFolder(DropboxClient client, string path)
        {
            var folderArg = new CreateFolderArg(path, false);

            if (!FolderExists(client, path))
            {
                var folder = await client.Files.CreateFolderV2Async(folderArg);

                Console.WriteLine("Folder: " + path + " created!");
                return(folder.Metadata);
            }
            else
            {
                return(new FolderMetadata());  //just a blank one.
            }
        }
Beispiel #11
0
        /// <summary>
        /// Creates the specified folder.
        /// </summary>
        /// <remarks>This demonstrates calling an rpc style api in the Files namespace.</remarks>
        /// <param name="path">The path of the folder to create.</param>
        /// <param name="client">The Dropbox client.</param>
        /// <returns>The result from the ListFolderAsync call.</returns>
        public async Task <DropboxFolderMetaData> CreateFolder(string path)
        {
            if (dropboxClient != null)
            {
                DropboxFolderMetaData dropboxFolder = new DropboxFolderMetaData();
                var folderArg = new CreateFolderArg(path);
                var folder    = await dropboxClient.Files.CreateFolderAsync(folderArg);

                if (folder != null)
                {
                    dropboxFolder.Name = folder.Name;
                }

                return(dropboxFolder);
            }

            return(null);
        }
        public async Task <FolderMetadata> CreateFolderAsync(string path)
        {
            var folderArg = new CreateFolderArg(path);

            try
            {
                using (var dbx = new DropboxClient(dropBoxAppToken))
                {
                    var folder = await dbx.Files.CreateFolderV2Async(folderArg);

                    return(folder.Metadata);
                }
            }
            catch
            {
                return(null);
            }
        }
Beispiel #13
0
        /// <summary>
        ///*** Creates the specified folder.
        /// *** Incase of error it set static variable MsgError with error details
        /// </summary>
        /// <remarks>This demonstrates calling an rpc style api in the Files namespace.</remarks>
        /// <param name="strFolderPath">The path to list.</param>
        /// <param name="objDropboxClient">DropBox Client Object</param>
        /// <returns>Creation Result Boolean</returns>
        public static async Task <bool> CreateFolder(object objDropboxClient, string strFolderPath)
        {
            try
            {
                //*** 1. Casting
                DropboxClient dropboxClient = (DropboxClient)objDropboxClient;

                var folderArg = new CreateFolderArg(strFolderPath);
                var folder    = await dropboxClient.Files.CreateFolderAsync(folderArg);

                return(true);
            }
            catch (Exception e) //*** Error
            {
                MsgError = e.ToString();

                return(false);
            }
        }
Beispiel #14
0
        private async Task <CreateFolderResult> CreateFolder(DropboxClient client, string path)
        {
            var folder = new CreateFolderResult();

            try
            {
                Console.WriteLine("--- Creating Folder ---");
                var folderArg = new CreateFolderArg(path);
                folder = await client.Files.CreateFolderV2Async(folderArg);

                Console.WriteLine("Folder: " + path + " created!");
                log_box.Items.Add("フォルダ" + path + "を作成しました");
            }
            catch (ApiException <CreateFolderError> ex)
            {
                string a = ex.Message;
                log_box.Items.Add(path + "の作成に問題が発生しました。すでにフォルダが存在している可能性があります\n\n理由:" + a);
            }
            return(folder);
        }
Beispiel #15
0
        /// <summary>
        /// Creates the specified folder.
        /// </summary>
        /// <remarks>This demonstrates calling an RPC style API in the Files namespace.</remarks>
        /// <param name="path">The path of the folder to create.</param>
        /// <returns>The result from the ListFolderAsync call.</returns>
        private async Task <bool> CreateNewFolderAsync(string path)
        {
            bool result = false;

            try
            {
                AppObjects.Log.Log("--- Creating Folder ---");
                var folderArg = new CreateFolderArg(path);
                var folder    = await this.dbc.Files.CreateFolderV2Async(folderArg);

                AppObjects.Log.Log("Folder: " + path + " created!");
                result = true;
            }
            catch (Exception ex)
            {
                AppObjects.Log.LogException(ex);
            }

            return(result);
        }
Beispiel #16
0
        public static bool CreateFolder(string path, DropboxClient client)
        {
            try {
                if (GetAccessTokenFromFile() == null)
                {
                    throw new Exception("Access Token is Null.");
                }

                if (GetAuthenticationURLFromFile() == null)
                {
                    throw new Exception("AuthenticationURI is Null");
                }

                var folderArg = new CreateFolderArg(path);
                var folder    = client.Files.CreateFolderV2Async(folderArg);
                var result    = folder.Result;
                return(true);
            } catch (Exception e) {
                return(false);
            }
        }
Beispiel #17
0
        /// <summary>
        /// Creates the specified folder.
        /// </summary>
        /// <remarks>This demonstrates calling an rpc style api in the Files namespace.</remarks>
        /// <param name="path">The path of the folder to create.</param>
        /// <param name="client">The Dropbox client.</param>
        /// <returns>The result from the ListFolderAsync call.</returns>
        private static FolderMetadata CreateFolder(DropboxClient client, string path)
        {
            FolderMetadata folder = null;

            try
            {
                folder = client.Files.GetMetadataAsync(path).Result as FolderMetadata;
            }
            catch (Exception ex)
            {
                if (ex.InnerException is ApiException <GetMetadataError> && ((ex.InnerException as ApiException <GetMetadataError>).ErrorResponse as GetMetadataError.Path).Value is LookupError.NotFound)
                {
                    var folderArg = new CreateFolderArg(path);
                    folder = client.Files.CreateFolderV2Async(folderArg).Result.Metadata;
                }
                else
                {
                    throw;
                }
            }
            return(folder);
        }
Beispiel #18
0
        public async Task <ActionResult> NewDirectory(string dirname)
        {
            List <DirViewModel> resultList = new List <DirViewModel>();

            using (var dbx = new DropboxClient(accessToken))
            {
                var folderArg = new CreateFolderArg(dirname);
                var result    = await dbx.Files.CreateFolderV2Async(folderArg);

                var listResult = await dbx.Files.ListFolderAsync(string.Empty);

                // show folders
                foreach (var item in listResult.Entries.Where(i => i.IsFolder))
                {
                    resultList.Add(new DirViewModel()
                    {
                        Path = item.PathDisplay, Name = item.Name
                    });
                }
            }
            return(View(resultList));
        }
        /// <summary>
        /// <para>Begins an asynchronous send to the create folder route.</para>
        /// </summary>
        /// <param name="path">Path in the user's Dropbox to create.</param>
        /// <param name="callback">The method to be called when the asynchronous send is
        /// completed.</param>
        /// <param name="callbackState">A user provided object that distinguished this send
        /// from other send requests.</param>
        /// <returns>An object that represents the asynchronous send request.</returns>
        public sys.IAsyncResult BeginCreateFolder(string path,
                                                  sys.AsyncCallback callback,
                                                  object callbackState = null)
        {
            var createFolderArg = new CreateFolderArg(path);

            return this.BeginCreateFolder(createFolderArg, callback, callbackState);
        }
        /// <summary>
        /// <para>Create a folder at a given path.</para>
        /// </summary>
        /// <param name="path">Path in the user's Dropbox to create.</param>
        /// <returns>The task that represents the asynchronous send operation. The TResult
        /// parameter contains the response from the server.</returns>
        /// <exception cref="Dropbox.Api.ApiException{CreateFolderError}">Thrown if there is an
        /// error processing the request; This will contain a <see
        /// cref="CreateFolderError"/>.</exception>
        public t.Task<FolderMetadata> CreateFolderAsync(string path)
        {
            var createFolderArg = new CreateFolderArg(path);

            return this.CreateFolderAsync(createFolderArg);
        }
        /// <summary>
        /// <para>Begins an asynchronous send to the create folder route.</para>
        /// </summary>
        /// <param name="createFolderArg">The request parameters.</param>
        /// <param name="callback">The method to be called when the asynchronous send is
        /// completed.</param>
        /// <param name="state">A user provided object that distinguished this send from other
        /// send requests.</param>
        /// <returns>An object that represents the asynchronous send request.</returns>
        public sys.IAsyncResult BeginCreateFolder(CreateFolderArg createFolderArg, sys.AsyncCallback callback, object state = null)
        {
            var task = this.CreateFolderAsync(createFolderArg);

            return enc.Util.ToApm(task, callback, state);
        }
 /// <summary>
 /// <para>Create a folder at a given path.</para>
 /// </summary>
 /// <param name="createFolderArg">The request parameters</param>
 /// <returns>The task that represents the asynchronous send operation. The TResult
 /// parameter contains the response from the server.</returns>
 /// <exception cref="Dropbox.Api.ApiException{CreateFolderError}">Thrown if there is an
 /// error processing the request; This will contain a <see
 /// cref="CreateFolderError"/>.</exception>
 public t.Task<FolderMetadata> CreateFolderAsync(CreateFolderArg createFolderArg)
 {
     return this.Transport.SendRpcRequestAsync<CreateFolderArg, FolderMetadata, CreateFolderError>(createFolderArg, "api", "/files/create_folder", CreateFolderArg.Encoder, FolderMetadata.Decoder, CreateFolderError.Decoder);
 }
Beispiel #23
0
 //public Task<FolderMetadata> CreateFolder(string path)
 //{
 //    var folderArg = new CreateFolderArg(path);
 //    var folder = DBClient.Files.CreateFolderV2Async(folderArg).Result;
 //    return folder.Metadata;
 //}
 public void CreateFolder(string path)
 {
     var folderArg = new CreateFolderArg(path);
     var folder    = DBClient.Files.CreateFolderV2Async(folderArg).Result;
 }
Beispiel #24
0
 public async Task CreateFolder(string folderPath)
 {
     CreateFolderArg cfa     = new CreateFolderArg(folderPath);
     var             updated = await dc.Files.CreateFolderV2Async(cfa);
 }
 /// <summary>
 /// <para>Create a folder at a given path.</para>
 /// <para>No file or folder may exist at the path. The parent folder will be created if
 /// it does not already exist (and so on). If the parent exists it must be a folder
 /// (and the same for any ancestor). If an ancestor is a shared folder it must have
 /// write access.</para>
 /// </summary>
 /// <param name="createFolderArg">The request parameters</param>
 /// <returns>The task that represents the asynchronous send operation. The TResult
 /// parameter contains the response from the server.</returns>
 /// <exception cref="Dropbox.Api.ApiException{PathError}">Thrown if there is an error
 /// processing the request; This will contain a <see cref="PathError"/>.</exception>
 public t.Task<FolderMetadata> CreateFolderAsync(CreateFolderArg createFolderArg)
 {
     return this.Transport.SendRpcRequestAsync<CreateFolderArg, FolderMetadata, PathError>(createFolderArg, "api", "/files/create_folder");
 }