DownloadWebFile throws 404 error

May 30, 2013 at 5:40 PM
Edited May 30, 2013 at 5:42 PM
Hi all,

I'm trying to download files from my skydrive account using the DownloadWebFile method, but even though I match the name of the file to the list of files on the skydrive it still throws a 404 (file not found) error when creating the file stream.

I've attached my code to see if anyone has any ideas.

Thanks in advance

Public Sub downloadSingleFile(ByVal folder As String, ByVal filename As String)
        Dim client = New SkyDriveServiceClient

        client.LogOn("user", "pwd")
        client.Timeout = 99999999
        Dim subFolderArray() As WebFolderInfo = Nothing
        Dim rootFolderArray() As WebFolderInfo = client.ListRootWebFolders()
        For i = 0 To UBound(rootFolderArray)
            If rootFolderArray(i).Name = "Documents" Then
                subFolderArray = client.ListSubWebFolders(rootFolderArray(i))
            End If
        For i = 0 To UBound(subFolderArray)
            If subFolderArray(i).Name = folder Then
                Dim fileInfo() As WebFileInfo = client.ListSubWebFiles(subFolderArray(i))
                For n = 0 To UBound(fileInfo)
                    If fileInfo(n).Name = filename Then
                        Using filestream As Stream = client.DownloadWebFile(fileInfo(n))
                        End Using
                        Exit Sub
                    End If

            End If

    End Sub
Jun 24, 2013 at 8:09 PM
I had the same issue. I was able to resolve the 404 being returne by editing SkyDriveServiceClient.Helpers.cs method EncodeWebFolderItemPath. Uncomment the the string replace lines of code except for .Replace("","^"). This is also mentioned in this post
Jun 25, 2013 at 9:07 AM
Thanks pneborg,

You're right it was a path issue.

I got around it in the end by manually adding the path to the download:
    fileInfo(n).Path = "/Documents/" & folder & "/" & subFolder & "/" & fileInfo(n).Name