How can i get the members of a Dropbox shared folder programmatically using c#? - c#

I want to get or find all the members of a shared folder from a Dropbox account. Currently I'm using DropNet, but there is no such option i found.

The Dropbox API does not currently have any way to programmatically get a list of shared folder members.

Use Spring Social dropbox framework for .Net. They have already provided some examples in it. In one of the example they have provided the code for listing all files for a particular type.
Additional Code:
//After creating dropbox service use the following code
//Following code searches the root folder, file of type "all" including subfolders
//To search a particular folder write the path in the first parameter of SearchAsync Method
//To list only "txt" files write ".txt" for the second parameter
dropbox.SearchAsync("", ".").ContinueWith(task =>
{
Console.WriteLine(task.Result.Count);
foreach (Entry file in task.Result)
{
Console.WriteLine(file.Path); //prints path
}
});

Related

How can i navigate files retrieved from oneDrive using rest like FileDialog?

I have retrieved a list of files from onedrive using the rest api call. It returns a json object with the file details and whether it is a directory or not.
So if the json object is returned and it has lets say 2 files and a directory , how can i navigate these using something similar to a file.dialog ?
Update:
I have created a winform and populated the names of the files to a memoedit. so for example it will display
testfile1.txt
fileuser.xls
Users <----- this is a directory
I want the user to be able to click on an item and if it is a file it will get the selected value if its a file , but navigate to the sub directory if it is a directory ?
On a side note do i need to check if its a directory then refetch the list of files within that directory via rest again and keep doing that ?

Autodesk BIM360: Create Folder and manage permission

I want to create a new Folder in my BIM360 Project by using the C# SDK. Unfortunately, I do not manage to get a ResourceId to define my parent folder.
I tried it like this:
CreateFolder folder = new CreateFolder();
string root_folder = "...";
folder.Data.Relationships.Parent.Data.Id = root_folder;
But the parent id must be from type ResourceId and I only have a string which contains the id. Until now, I have not found a conversion between string and resource id(ResourceId only supports the standard-constructor)
I have also tried to make a GET request on the root folder to receive all its information. But there I also receive an id as a string.
So how am I supposed to create a resource id for my folder?
And just one little additional question: If I succeed in creating a folder, how can I manage the permission? Is it even possible to do so via webservice?
Thanks in advance
I want to create a new Folder in my BIM360 Project by using the C# SDK
As of August/2017, to create a BIM 360 Docs folder you need to POST Command with this JSON body. In any case, the resource id is the parent folder, it must be another folder, either one default folder on BIM 360 Docs (e.g. Plans) or topFolder on BIM 360 Team.
But there I also receive an id as a string. So how am I supposed to
create a resource id for my folder?
The parent full href can be spliced by / (forward slash) so you can access the parent folder. This sample demonstrates it.
If I succeed in creating a folder, how can I manage the permission? Is
it even possible to do so via webservice?
Again, as of August/2017, we cannot manage permissions by API.

Searching in Dropbox using SearchAsync not showing all results in C# using .NET SDK API v2

Suppose I want to show all files from a Dropbox folder using SearchAsync in C#.
The "query" argument of SearchAsync is mandatory so that it filters records from the Dropbox folder files. How could I populate all files from a folder using SearchAsync.File indexing is required so that I have to use SearchAsync. I'm using the SearchAsync like below-
await client.Files.SearchAsync("path"," ");
If anyone has any idea please share.
The SearchAsync method requires a query, and doesn't support listing everything in a folder.
Instead, to list everything in a folder, you should use the ListFolderAsync method.

How to extract name/data from database and use it as my folder name which is created dynamically in asp.net c# using server.MapPath()?

I have used AjaxFileUpload to upload multiple image files. Now i want to store the uploaded images inside rootfolder>subfolder.
The rootfolder is in the name of the user.
The rootfolder is created dynamically by taking the session of the user who has logged in
Like this:
string username = Session["username"].ToString();
I am able to create this folder and save images in it. but i want to save it in subfolder.
the subfolder is also created dynamically but this time i have to take the value(id) from the database and name the folder by that id name. (this is so that i can refer to the database)
I know how to create a new folder using Server.MapPath();
Here is the code for it in brief
using System.IO
if (Directory.Exists(Server.MapPath(uploadPath))) return;
else Directory.CreateDirectory(Server.MapPath(uploadPath));
where uploadPath is the folder's name i want to create dynamiclly.
but how do I include the subfolder too in my Server.MapPath() so as to make my path as rootfolder/subfolder ?
Small example to make the question understandable.
I am a seller. I have posted 4 ads online.
Now when i am posting my 5th ad i want to include many images.
these images should be saved in the folder
Seller/5/imagename.jpg.
(where Seller is the username(main folder), 5 is the advertID in the database and the name of the subfolder)
How do i do this? Please help.
I am using asp.net c#
As far as I know, you can't do one statement to create folder and subfolders because you need the folder to be created first.
You have all of the code you need, you just need to repeat it. Check to see if the main folder (username) exists. If it doesn't create it, if it does, check to see if the subfolder exists. If it doesn't, create it.
Just work through that logic and you'll be set.
User Path.Combine to add your root and the user id:
var userPath = Path.Combine(uploadPath,userID)
This is the safest way to create what you need. The Directory.CreateDirectory method will create all the subfolders as needed:
var userPath = Path.Combine(uploadPath,userID)
if (Directory.Exists(Server.MapPath(userPath))) return;
else Directory.CreateDirectory(Server.MapPath(userPath));

how to create folder on server from code in c#?

Is there any way to show user popup to give the name to create folder
And with that if he does not want to create folder then he should be shown the list of folders to which he want to save the file
Is it proper way that I create a popup with javascript with the list of folders on my server and put a textbox and button to save the new and in code we will create directory in code passed with textbox?
string pathToCreate = "~/UserFolders/" + TextBox1.Text;
if(Directory.Exists(Server.MapPath(pathToCreate))
{
//In here, start looping and modify the path to create to add a number
//until you get the value needed
}
//Now you know it is ok, create it
Directory.CreateDirectory(Server.MapPath(pathToCreate));
string targetPath = Server.MapPath("FolderName"); //with complete path
if (!System.IO.Directory.Exists(targetPath))
{
System.IO.Directory.CreateDirectory(targetPath);
fileToUpload.PostedFile.SaveAs(targetPath + ImageFileName);
}
else
{
fileToUpload.PostedFile.SaveAs(targetPath + ImageFileName);
}
As I mentioned by commenting that Functionality like SaveFileDialog is only possible in Windows Forms application, you cannot do this in asp.net
The alternatives in asp.net are difficult however as an alternate there is a third party editor available on the web called CKEditor 3.x Developer's Guide.
You can use File Browser (Uploader) for the purpose you want to achieve.
to create folder :
System.IO.Directory.CreateDirectory(newPath);//newpath is your folder creating path
If you are developing web applications (I can see you have tagged your question as asp.net), you do not need to worry about the pop up window. You just send the file through the Response and the download window will be shown by the browser.
Using the Example given in How to Create a Folder or File You can create a folder, but in asp.net you can not Use open file dialog or save file dialog functionalities, this will work only in C# Windows forms application.
Web applications and the HTTP protocol do not support direct manipulation of the server-side file system. In fact, that would be a dangerous idea.
It sounds like you have a base folder somewhere on the web server where you want users to be able to upload files, with some user control over subfolders and location of the uploaded file. I would suggest dong this by presenting the file system in a tree view or a list of links (where the links let you navigate up/down the folder tree). Combine this with a file input and you've got yourself a solution. HOWEVER, be very careful to control and cleanse the specified file name for the uploaded file. There are many combinations (such as utilizing "..") that can allow the user to hack into unwanted file locations on your server.

Categories

Resources