OneDrive file download simplified
-
Basically I take in a standard URI starting with /me/... like /me/skydrive/folder1/folder2/file and then return the file. The way it is suppose to work. All written in visual basic - just to be different. Programmed using Unidex so feel free to ask what this or that does. This is a working example that does not need to be debugged The only thing Unidex does in this example is parses the words from the URI, once you create your own code to put each word in a list you should be able to use this same logic.
'Take in any string, parse the information and returns the file from the users OneDrive
Public Async Function RetrieveFile(FullPath As String) As Task(Of Windows.Storage.IStorageFile)Dim CurrentFolderInfo As Microsoft.Live.LiveOperationResult Dim CurrentlyFoundFolders As Microsoft.Live.LiveOperationResult Dim CurrentlyFoundFiles As Microsoft.Live.LiveOperationResult Dim FileName = "" Dim Result As Unidex.Reference.OldStructures.Strings = FullPath If Result.Items(0).ToLower <> "me" Then Throw New Exception("First word of path must be me!") Select Case Result.Items(1).ToLower Case "skydrive" : CurrentFolderInfo = Await Me.GetRootFolder Case "calendars" : CurrentFolderInfo = Await Me.GetCalendars Case "contacts" : CurrentFolderInfo = Await Me.GetContacts Case "events" : CurrentFolderInfo = Await Me.GetEvents Case Else : Throw New Exception("Second word of path is invalid!") End Select CurrentlyFoundFolders = Await Me.GetFolders(CurrentFolderInfo) For Each Current In Result.Separators Try Select Case Current.Separator Case "/", "\\" Select Case Current.WordBefore Case "", "me", "skydrive", "calendars", "contacts", "events" Case Else CurrentFolderInfo = Await Me.GetFolder(Current.WordBefore, CurrentlyFoundFolders) CurrentlyFoundFolders = Await Me.GetFolders(CurrentFolderInfo) End Select Case "." CurrentlyFoundFiles = Await Me.GetFiles(CurrentFolderInfo) FileName = Current.WordBefore & "." & Current.WordAfter Return Await Me.GetFile(CurrentFolderInfo, FileName) End Select Catc
-
Basically I take in a standard URI starting with /me/... like /me/skydrive/folder1/folder2/file and then return the file. The way it is suppose to work. All written in visual basic - just to be different. Programmed using Unidex so feel free to ask what this or that does. This is a working example that does not need to be debugged The only thing Unidex does in this example is parses the words from the URI, once you create your own code to put each word in a list you should be able to use this same logic.
'Take in any string, parse the information and returns the file from the users OneDrive
Public Async Function RetrieveFile(FullPath As String) As Task(Of Windows.Storage.IStorageFile)Dim CurrentFolderInfo As Microsoft.Live.LiveOperationResult Dim CurrentlyFoundFolders As Microsoft.Live.LiveOperationResult Dim CurrentlyFoundFiles As Microsoft.Live.LiveOperationResult Dim FileName = "" Dim Result As Unidex.Reference.OldStructures.Strings = FullPath If Result.Items(0).ToLower <> "me" Then Throw New Exception("First word of path must be me!") Select Case Result.Items(1).ToLower Case "skydrive" : CurrentFolderInfo = Await Me.GetRootFolder Case "calendars" : CurrentFolderInfo = Await Me.GetCalendars Case "contacts" : CurrentFolderInfo = Await Me.GetContacts Case "events" : CurrentFolderInfo = Await Me.GetEvents Case Else : Throw New Exception("Second word of path is invalid!") End Select CurrentlyFoundFolders = Await Me.GetFolders(CurrentFolderInfo) For Each Current In Result.Separators Try Select Case Current.Separator Case "/", "\\" Select Case Current.WordBefore Case "", "me", "skydrive", "calendars", "contacts", "events" Case Else CurrentFolderInfo = Await Me.GetFolder(Current.WordBefore, CurrentlyFoundFolders) CurrentlyFoundFolders = Await Me.GetFolders(CurrentFolderInfo) End Select Case "." CurrentlyFoundFiles = Await Me.GetFiles(CurrentFolderInfo) FileName = Current.WordBefore & "." & Current.WordAfter Return Await Me.GetFile(CurrentFolderInfo, FileName) End Select Catc
Probably better posted as a Tip/Trick rather than in the lounge!!
Quad skating his way through the world since the early 80's... Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!
-
Probably better posted as a Tip/Trick rather than in the lounge!!
Quad skating his way through the world since the early 80's... Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!
still new at this
-
still new at this
Lounge postings disappear rapidly. After 3 months, it'll be hard to find it here and people won't come upon it. A Tip has longevity.
-
Lounge postings disappear rapidly. After 3 months, it'll be hard to find it here and people won't come upon it. A Tip has longevity.
Where do I find these tips?
-
Where do I find these tips?
On the front page, or under articles. A tip/trick is a short article. Click the articles menu option and choose "Submit an article or tip" from the dropdown to create your own tip. Just make sure you select Tip/Trick in the appropriate combo on the right hand side.
-
still new at this
ColborneGreg wrote:
still new at this
Take a look at http://www.codeproject.com/KB/FAQs/[^] and http://www.codeproject.com/info/Submit.aspx[^].
-
Basically I take in a standard URI starting with /me/... like /me/skydrive/folder1/folder2/file and then return the file. The way it is suppose to work. All written in visual basic - just to be different. Programmed using Unidex so feel free to ask what this or that does. This is a working example that does not need to be debugged The only thing Unidex does in this example is parses the words from the URI, once you create your own code to put each word in a list you should be able to use this same logic.
'Take in any string, parse the information and returns the file from the users OneDrive
Public Async Function RetrieveFile(FullPath As String) As Task(Of Windows.Storage.IStorageFile)Dim CurrentFolderInfo As Microsoft.Live.LiveOperationResult Dim CurrentlyFoundFolders As Microsoft.Live.LiveOperationResult Dim CurrentlyFoundFiles As Microsoft.Live.LiveOperationResult Dim FileName = "" Dim Result As Unidex.Reference.OldStructures.Strings = FullPath If Result.Items(0).ToLower <> "me" Then Throw New Exception("First word of path must be me!") Select Case Result.Items(1).ToLower Case "skydrive" : CurrentFolderInfo = Await Me.GetRootFolder Case "calendars" : CurrentFolderInfo = Await Me.GetCalendars Case "contacts" : CurrentFolderInfo = Await Me.GetContacts Case "events" : CurrentFolderInfo = Await Me.GetEvents Case Else : Throw New Exception("Second word of path is invalid!") End Select CurrentlyFoundFolders = Await Me.GetFolders(CurrentFolderInfo) For Each Current In Result.Separators Try Select Case Current.Separator Case "/", "\\" Select Case Current.WordBefore Case "", "me", "skydrive", "calendars", "contacts", "events" Case Else CurrentFolderInfo = Await Me.GetFolder(Current.WordBefore, CurrentlyFoundFolders) CurrentlyFoundFolders = Await Me.GetFolders(CurrentFolderInfo) End Select Case "." CurrentlyFoundFiles = Await Me.GetFiles(CurrentFolderInfo) FileName = Current.WordBefore & "." & Current.WordAfter Return Await Me.GetFile(CurrentFolderInfo, FileName) End Select Catc
-
ohhh Christan Graus is your man - i'm sure he was talking about pretty much this exact stuff the other day Drop him a message - hes very helpful Bryce
MCAD ---
The Microsoft documentation is horrifying to get this job done, this here is a working example for people in how to achieve something that Microsoft Virtual Academy said had to be done using URI relative to a single file and you couldn't navigate through the OneDrive like any other folder.
-
On the front page, or under articles. A tip/trick is a short article. Click the articles menu option and choose "Submit an article or tip" from the dropdown to create your own tip. Just make sure you select Tip/Trick in the appropriate combo on the right hand side.
Thank you
-
Thank you
You're welcome
-
On the front page, or under articles. A tip/trick is a short article. Click the articles menu option and choose "Submit an article or tip" from the dropdown to create your own tip. Just make sure you select Tip/Trick in the appropriate combo on the right hand side.
Pete O'Hanlon wrote:
On the front page, or under articles. A tip/trick is a short article. Click the articles menu option and choose "Submit an article or tip" from the dropdown to create your own tip. Just make sure you select Tip/Trick in the appropriate combo on the right hand side.
Hey, that's useful information. You should put it on the Tips/Tricks forum.
I wanna be a eunuchs developer! Pass me a bread knife!