Click here to Skip to main content
13,351,243 members (49,532 online)

Welcome to the Lounge

   

For discussing anything related to a software developer's life. Technical discussions are encouraged, but click here to ask your programming questions.

The Lounge is rated PG. If you're about to post something you wouldn't want your kid sister to read then don't post it. No flame wars, no abusive conduct, no programming questions and please don't post ads.
 
GeneralRe: Death Walk Pin
Super Lloyd11-Aug-14 22:01
memberSuper Lloyd11-Aug-14 22:01 
GeneralRe: Death Walk Pin
V.11-Aug-14 22:06
professionalV.11-Aug-14 22:06 
GeneralRe: Death Walk Pin
Super Lloyd11-Aug-14 22:24
memberSuper Lloyd11-Aug-14 22:24 
GeneralRe: Death Walk Pin
Rage11-Aug-14 23:45
professionalRage11-Aug-14 23:45 
GeneralRe: Death Walk Pin
Marc Clifton12-Aug-14 4:15
protectorMarc Clifton12-Aug-14 4:15 
GeneralRe: Death Walk Pin
V.12-Aug-14 4:20
professionalV.12-Aug-14 4:20 
GeneralRe: Death Walk Pin
Gary Wheeler12-Aug-14 8:10
memberGary Wheeler12-Aug-14 8:10 
GeneralOneDrive file download simplified Pin
ColborneGreg11-Aug-14 21:30
memberColborneGreg11-Aug-14 21:30 
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
           Catch
           End Try
       Next

       Throw New Exception("Sequence completed without locating a filename.")
   End Function

'Get a Directory
   Public Async Function GetFolder(FolderName As String, FolderInfo As ResultsStructure) As Task(Of Microsoft.Live.LiveOperationResult)
       Dim SubFolder As ResultsStructure = FolderInfo.Results.FirstOrDefault(Function(f) f.Key = FolderName)
       Return Await LiveConnectClient.GetAsync(SubFolder.ID)
   End Function

   'Get the folders of a directory of any given name
   Public Async Function GetFolders(FolderInfo As ResultsStructure) As Task(Of Microsoft.Live.LiveOperationResult)
       Return Await LiveConnectClient.GetAsync(FolderInfo.ID & "/files?filter=folders")
   End Function


   'Get the files of a directory of any given name
   Public Async Function GetFiles(FolderInfo As ResultsStructure) As Task(Of Microsoft.Live.LiveOperationResult)
       Return Await LiveConnectClient.GetAsync(FolderInfo.ID & "/files")
   End Function


   'Get the URI of any given file name
   Public Async Function GetFile(FolderInfo As ResultsStructure, FileName As String) As Task(Of Microsoft.Live.LiveOperationResult)
       Dim File As ResultsStructure = FolderInfo.Results.FirstOrDefault(Function(f) f.Key = FileName)
       Return Await LiveConnectClient.GetAsync(File.DownloadPath)
   End Function


   'Create local target of the file in a temporary folder
   Public Async Function TemporaryStorageFile(FileName As String) As Task(Of Windows.Storage.StorageFile)
       Return Await Windows.Storage.ApplicationData.Current.TemporaryFolder.CreateFileAsync(FileName, Windows.Storage.CreationCollisionOption.ReplaceExisting)
   End Function



   'Set as background task for the OS the continue the process
   Public Async Function SetBackgroundTask(DownLoadPath As String, OutputFile As Windows.Storage.StorageFile) As Task(Of Microsoft.Live.LiveDownloadOperationResult)
       Return Await LiveConnectClient.BackgroundDownloadAsync(DownLoadPath, OutputFile)
   End Function


modified 12-Aug-14 2:53am.

GeneralRe: OneDrive file download simplified Pin
_Damian S_11-Aug-14 21:40
professional_Damian S_11-Aug-14 21:40 
GeneralRe: OneDrive file download simplified Pin
ColborneGreg11-Aug-14 21:43
memberColborneGreg11-Aug-14 21:43 
GeneralRe: OneDrive file download simplified Pin
Pete O'Hanlon11-Aug-14 21:53
protectorPete O'Hanlon11-Aug-14 21:53 
GeneralRe: OneDrive file download simplified Pin
ColborneGreg11-Aug-14 21:54
memberColborneGreg11-Aug-14 21:54 
GeneralRe: OneDrive file download simplified Pin
Pete O'Hanlon11-Aug-14 22:03
protectorPete O'Hanlon11-Aug-14 22:03 
GeneralRe: OneDrive file download simplified Pin
ColborneGreg12-Aug-14 6:12
memberColborneGreg12-Aug-14 6:12 
GeneralRe: OneDrive file download simplified Pin
Pete O'Hanlon12-Aug-14 7:09
protectorPete O'Hanlon12-Aug-14 7:09 
GeneralRe: OneDrive file download simplified Pin
Mark_Wallace12-Aug-14 9:45
memberMark_Wallace12-Aug-14 9:45 
AnswerRe: OneDrive file download simplified Pin
Richard MacCutchan11-Aug-14 22:35
protectorRichard MacCutchan11-Aug-14 22:35 
GeneralRe: OneDrive file download simplified Pin
bryce11-Aug-14 22:44
memberbryce11-Aug-14 22:44 
GeneralRe: OneDrive file download simplified Pin
ColborneGreg12-Aug-14 6:03
memberColborneGreg12-Aug-14 6:03 
GeneralRIP Robin Williams Pin
pkfox11-Aug-14 21:03
memberpkfox11-Aug-14 21:03 
GeneralRe: RIP Robin Williams Pin
_Damian S_11-Aug-14 21:04
professional_Damian S_11-Aug-14 21:04 
GeneralRe: RIP Robin Williams Pin
pkfox11-Aug-14 21:07
memberpkfox11-Aug-14 21:07 
GeneralRe: RIP Robin Williams Pin
5imone11-Aug-14 22:39
professional5imone11-Aug-14 22:39 
GeneralRe: Robin Williams Pin
TheWebDeveloper11-Aug-14 22:07
memberTheWebDeveloper11-Aug-14 22:07 
QuestionHow can I upload my Source code for download in an article? Pin
Gihan Liyanage11-Aug-14 20:19
memberGihan Liyanage11-Aug-14 20:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy |
Web04 | 2.8.180111.1 | Last Updated 20 Jan 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid