Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. OneDrive file download simplified

OneDrive file download simplified

Scheduled Pinned Locked Moved The Lounge
tutorial
12 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    ColborneGreg
    wrote on last edited by
    #1

    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
    
    _ B 2 Replies Last reply
    0
    • C ColborneGreg

      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
      
      _ Offline
      _ Offline
      _Damian S_
      wrote on last edited by
      #2

      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!!

      C 1 Reply Last reply
      0
      • _ _Damian S_

        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!!

        C Offline
        C Offline
        ColborneGreg
        wrote on last edited by
        #3

        still new at this

        P L 2 Replies Last reply
        0
        • C ColborneGreg

          still new at this

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          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.

          C 1 Reply Last reply
          0
          • P Pete OHanlon

            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.

            C Offline
            C Offline
            ColborneGreg
            wrote on last edited by
            #5

            Where do I find these tips?

            P 1 Reply Last reply
            0
            • C ColborneGreg

              Where do I find these tips?

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              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.

              C M 2 Replies Last reply
              0
              • C ColborneGreg

                still new at this

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                ColborneGreg wrote:

                still new at this

                Take a look at http://www.codeproject.com/KB/FAQs/[^] and http://www.codeproject.com/info/Submit.aspx[^].

                1 Reply Last reply
                0
                • C ColborneGreg

                  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
                  
                  B Offline
                  B Offline
                  bryce
                  wrote on last edited by
                  #8

                  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 ---

                  C 1 Reply Last reply
                  0
                  • B bryce

                    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 ---

                    C Offline
                    C Offline
                    ColborneGreg
                    wrote on last edited by
                    #9

                    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.

                    1 Reply Last reply
                    0
                    • P Pete OHanlon

                      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.

                      C Offline
                      C Offline
                      ColborneGreg
                      wrote on last edited by
                      #10

                      Thank you

                      P 1 Reply Last reply
                      0
                      • C ColborneGreg

                        Thank you

                        P Offline
                        P Offline
                        Pete OHanlon
                        wrote on last edited by
                        #11

                        You're welcome

                        1 Reply Last reply
                        0
                        • P Pete OHanlon

                          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.

                          M Offline
                          M Offline
                          Mark_Wallace
                          wrote on last edited by
                          #12

                          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!

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups