|
yeah still limping today...
|
|
|
|
|
And people say I'm crazy (I'm a runner, and I've done four marathons) ...
Software Zen: delete this;
|
|
|
|
|
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.
|
|
|
|
|
Probably better posted as a Tip/Trick rather than in the lounge!!
|
|
|
|
|
|
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?
|
|
|
|
|
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!
|
|
|
|
|
|
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.
|
|
|
|
|
|
Again? He died earlier today too!!
|
|
|
|
|
Oops didn't see the post
We can’t stop here, this is bat country - Hunter S Thompson RIP
|
|
|
|
|
|
pkfox wrote: Very funny crazy man
For killing himself
|
|
|
|
|
I used 7 Zip because, when I upload as Zip it says :"one or more file cannot upload". When I upload the zip file it doesn't give the link to download the source link up side of the article. Do I want to give the link manually or any other methods to do that ?
Gihan Liyanage
http://gihansampathliyanage.wordpress.com
|
|
|
|
|
Why are you using 7Zip, I have found that to be flaky in past with some systems.
If you are on Windows box, simply select all the files in a folder you want to include in the zip and use the right click Send To compressed folder. upload that file.
|
|
|
|
|
Yes I did that Dave, Then I got the above mentioned error message. I did not have any exe files compressed. I double checked that. Any way if I uploaded the zip file it will be Automatically update the article header. Or I should manually give the link ?
Gihan Liyanage
http://gihansampathliyanage.wordpress.com
|
|
|
|
|
Sorry don't quite understand what you are on about. maybe too early in the morning! (06:37am here).
I occassionally see that error message. Simply save the draft of your article, then close and open the article for editing again, then re-try to upload the files. That usually works.
Once the file is in the list, simply click the little icon to the left of the file in the list and that will add it to the article text with the appropriate mark up.
Read the Submission Guidelines and the Article FAQ (link on the guidelines page) if you haven't done so already: http://www.codeproject.com/info/Submit.aspx[^]
|
|
|
|
|
Thank you for the answer Dave. I tried as you said. I think uploading zip from may Machine has a problem, because of network policy. That may be the problem. I will try from an another network later. Thank you again for valuable help.
Gihan Liyanage
http://gihansampathliyanage.wordpress.com
|
|
|
|
|
CP has an Author's Forum which is the perfect place to ask this question: [^].
You might want to consider the fact that posting your e-mail address in any public on-line forum will probably mean your mailbox will be fruitful and multiply endlessly, which, if you enjoy spam, could be a good thing.
cheers, Bill
“I have diligently numbered the days of pure and genuine happiness which have fallen to my lot: They amount to 14.” Abd-Ar Rahman III, Caliph of Cordoba, circa 950CE.
modified 12-Aug-14 3:57am.
|
|
|
|