Click here to Skip to main content
15,896,118 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Death Walk Pin
Super Lloyd11-Aug-14 21:01
Super Lloyd11-Aug-14 21:01 
GeneralRe: Death Walk Pin
V.11-Aug-14 21:06
professionalV.11-Aug-14 21:06 
GeneralRe: Death Walk Pin
Super Lloyd11-Aug-14 21:24
Super Lloyd11-Aug-14 21:24 
GeneralRe: Death Walk Pin
Rage11-Aug-14 22:45
professionalRage11-Aug-14 22:45 
GeneralRe: Death Walk Pin
Marc Clifton12-Aug-14 3:15
mvaMarc Clifton12-Aug-14 3:15 
GeneralRe: Death Walk Pin
V.12-Aug-14 3:20
professionalV.12-Aug-14 3:20 
GeneralRe: Death Walk Pin
Gary Wheeler12-Aug-14 7:10
Gary Wheeler12-Aug-14 7:10 
GeneralOneDrive file download simplified Pin
ColborneGreg11-Aug-14 20:30
ColborneGreg11-Aug-14 20: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 20:40
professional_Damian S_11-Aug-14 20:40 
GeneralRe: OneDrive file download simplified Pin
ColborneGreg11-Aug-14 20:43
ColborneGreg11-Aug-14 20:43 
GeneralRe: OneDrive file download simplified Pin
Pete O'Hanlon11-Aug-14 20:53
mvePete O'Hanlon11-Aug-14 20:53 
GeneralRe: OneDrive file download simplified Pin
ColborneGreg11-Aug-14 20:54
ColborneGreg11-Aug-14 20:54 
GeneralRe: OneDrive file download simplified Pin
Pete O'Hanlon11-Aug-14 21:03
mvePete O'Hanlon11-Aug-14 21:03 
GeneralRe: OneDrive file download simplified Pin
ColborneGreg12-Aug-14 5:12
ColborneGreg12-Aug-14 5:12 
GeneralRe: OneDrive file download simplified Pin
Pete O'Hanlon12-Aug-14 6:09
mvePete O'Hanlon12-Aug-14 6:09 
GeneralRe: OneDrive file download simplified Pin
Mark_Wallace12-Aug-14 8:45
Mark_Wallace12-Aug-14 8:45 
AnswerRe: OneDrive file download simplified Pin
Richard MacCutchan11-Aug-14 21:35
mveRichard MacCutchan11-Aug-14 21:35 
GeneralRe: OneDrive file download simplified Pin
bryce11-Aug-14 21:44
bryce11-Aug-14 21:44 
GeneralRe: OneDrive file download simplified Pin
ColborneGreg12-Aug-14 5:03
ColborneGreg12-Aug-14 5:03 
GeneralRIP Robin Williams Pin
pkfox11-Aug-14 20:03
professionalpkfox11-Aug-14 20:03 
GeneralRe: RIP Robin Williams Pin
_Damian S_11-Aug-14 20:04
professional_Damian S_11-Aug-14 20:04 
GeneralRe: RIP Robin Williams Pin
pkfox11-Aug-14 20:07
professionalpkfox11-Aug-14 20:07 
GeneralRe: RIP Robin Williams Pin
5imone11-Aug-14 21:39
professional5imone11-Aug-14 21:39 
GeneralRe: Robin Williams Pin
TheWebDeveloper11-Aug-14 21:07
TheWebDeveloper11-Aug-14 21:07 
QuestionHow can I upload my Source code for download in an article? Pin
Gihan Liyanage11-Aug-14 19:19
professionalGihan Liyanage11-Aug-14 19: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.