How to download/upload files from/to SharePoint 2013 using CSOM?

后端 未结 8 2172
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-30 20:19

I am developing a Win8 (WinRT, C#, XAML) client application (CSOM) that needs to download/upload files from/to SharePoint 2013.

How do I do the Download/Upload?

8条回答
  •  孤独总比滥情好
    2020-11-30 20:53

    Private Sub DownloadFile(relativeUrl As String, destinationPath As String, name As String)
        Try
            destinationPath = Replace(destinationPath + "\" + name, "\\", "\")
            Dim fi As FileInformation = Microsoft.SharePoint.Client.File.OpenBinaryDirect(Me.context, relativeUrl)
            Dim down As Stream = System.IO.File.Create(destinationPath)
            Dim a As Integer = fi.Stream.ReadByte()
            While a <> -1
                down.WriteByte(CType(a, Byte))
                a = fi.Stream.ReadByte()
            End While
        Catch ex As Exception
            ToLog(Type.ERROR, ex.Message)
        End Try
    End Sub
    

提交回复
热议问题