Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Downloading File[SOLVED] #42

Closed
woramon opened this issue May 5, 2016 · 5 comments
Closed

Downloading File[SOLVED] #42

woramon opened this issue May 5, 2016 · 5 comments

Comments

@woramon
Copy link

woramon commented May 5, 2016

I want to download the file in the user's path. Example:
string Path = folder\somefolder\somefolder2\somefile.file This can be change and I want to download "somefile.file" help me please.

@gpailler
Copy link
Owner

gpailler commented May 6, 2016

I don't really understand your question. folder\somefolder\somefolder2\somefile.file is the storage path on your mega account?

@woramon
Copy link
Author

woramon commented May 6, 2016

Yes it is but its In a different path for each user's mega account, not mine. Example:
user1 file path for download:string Path = folder\somefolder\somefolder2\somefile.file
user2 file path for download: string Path = folder2\somefolder2\somefile2.file
user3 ....

@gpailler
Copy link
Owner

gpailler commented May 6, 2016

You can use the following to get your file:

var nodes = megaApiClientInstance.GetNodes();
var root = nodes.Single(n.Type == NodeType.Root);
var level1 = megaApiClientInstance.GetNodes(root).Single(n => n.Type == NodeType.Folder && n.Name == "folder");
var level2 = megaApiClientInstance.GetNodes(level1).Single(n => n.Type == NodeType.Folder && n.Name == "somefolder");
var level3 = megaApiClientInstance.GetNodes(level2).Single(n => n.Type == NodeType.Folder && n.Name == "somefolder2");
var file = megaApiClientInstance.GetNode(level3).Single(n => n.Type == NodeType.File && n.Name == "somefile.file");

If your file has an unique name, another way is to request it directly

var file = megaApiClientInstance.GetNodes().Single(n => n.Type == NodeType.File && n.Name == "somefile.file");

(it works because mega.nz stores all files/folders in a flat list and GetNodes() methods returns all nodes.)

@woramon
Copy link
Author

woramon commented May 6, 2016

The second worked. I didn't know this method works like this. I think You can fill wiki more. You can give information about how methods works and the usage . Thank you so much. You saved my life 👍

@woramon woramon changed the title Downloading File Downloading File[SOLVED] May 6, 2016
@gpailler
Copy link
Owner

gpailler commented May 6, 2016

😄 Feel free to contribute and add samples...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants