Click here to Skip to main content
12,630,137 members (27,533 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: CCC 12/8/14 + Bonus one. Pin
DaveAuld11-Aug-14 22:48
protectorDaveAuld11-Aug-14 22:48 
GeneralRobin Williams put me in a state of confusion this morning! Pin
DaveAuld11-Aug-14 21:44
protectorDaveAuld11-Aug-14 21:44 
GeneralRe: Robin Williams put me in a state of confusion this morning! Pin
Dalek Dave11-Aug-14 21:53
memberDalek Dave11-Aug-14 21:53 
GeneralOT: Math stuff Pin
DaveAuld11-Aug-14 22:44
protectorDaveAuld11-Aug-14 22:44 
GeneralRe: OT: Math stuff Pin
Dalek Dave11-Aug-14 23:02
memberDalek Dave11-Aug-14 23:02 
GeneralDeath Walk Pin
V.11-Aug-14 21:31
professionalV.11-Aug-14 21:31 
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 
AnswerRe: How can I upload my Source code for download in an article? Pin
DaveAuld11-Aug-14 20:28
protectorDaveAuld11-Aug-14 20:28 
GeneralRe: How can I upload my Source code for download in an article? Pin
Gihan Liyanage11-Aug-14 20:33
memberGihan Liyanage11-Aug-14 20:33 
GeneralRe: How can I upload my Source code for download in an article? Pin
DaveAuld11-Aug-14 20:41
protectorDaveAuld11-Aug-14 20:41 
GeneralRe: How can I upload my Source code for download in an article? Pin
Gihan Liyanage11-Aug-14 21:12
memberGihan Liyanage11-Aug-14 21:12 
AnswerRe: How can I upload my Source code for download in an article? Pin
BillWoodruff11-Aug-14 21:20
professionalBillWoodruff11-Aug-14 21:20 
GeneralRe: How can I upload my Source code for download in an article? Pin
Gihan Liyanage11-Aug-14 21:27
memberGihan Liyanage11-Aug-14 21:27 
GeneralIn unrelated news Pin
Christian Graus11-Aug-14 19:12
protectorChristian Graus11-Aug-14 19:12 
GeneralRe: In unrelated news Pin
Johnny J.11-Aug-14 19:30
professionalJohnny J.11-Aug-14 19:30 
GeneralRe: In unrelated news Pin
Christian Graus11-Aug-14 19:32
protectorChristian Graus11-Aug-14 19:32 
GeneralRe: In unrelated news Pin
Johnny J.11-Aug-14 19:38
professionalJohnny J.11-Aug-14 19:38 
GeneralRe: In unrelated news Pin
_Maxxx_11-Aug-14 19:45
professional_Maxxx_11-Aug-14 19:45 
GeneralRe: In unrelated news Pin
Christian Graus11-Aug-14 19:48
protectorChristian Graus11-Aug-14 19:48 
GeneralRe: In unrelated news Pin
_Maxxx_11-Aug-14 19:49
professional_Maxxx_11-Aug-14 19:49 
GeneralRe: In unrelated news Pin
SoMad11-Aug-14 20:08
professionalSoMad11-Aug-14 20:08 
GeneralRe: In unrelated news Pin
Christian Graus11-Aug-14 20:11
protectorChristian Graus11-Aug-14 20:11 
GeneralRe: In unrelated news Pin
_Maxxx_11-Aug-14 20:46
professional_Maxxx_11-Aug-14 20:46 
GeneralRe: In unrelated news Pin
l a u r e n12-Aug-14 0:31
memberl a u r e n12-Aug-14 0:31 
GeneralRe: In unrelated news Pin
Christian Graus12-Aug-14 0:33
protectorChristian Graus12-Aug-14 0:33 
GeneralRe: In unrelated news Pin
l a u r e n12-Aug-14 0:37
memberl a u r e n12-Aug-14 0:37 

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 | Mobile
Web02 | 2.8.161205.3 | Last Updated 7 Dec 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid