使用vb.net为vs2010显示.ppt /.pptx文件

时间:2015-04-16 12:05:27

标签: asp.net .net vb.net visual-studio-2010 mime-types

我使用以下代码显示.pdf文件,但相同的代码不适用于.ppt / .pptx文件。需要建议。

If file.Name.Contains(Left(lblMth.Text, 3) & lblYr.Text) Then
    Response.Clear()
    Response.ClearContent()
    Response.ClearHeaders()

    Dim path As String = file.FullName 'strLine & GridView1.Rows(index).Cells(1).Text()
    Dim client As New WebClient()
    Dim buffer As [Byte]() = client.DownloadData(path)

    If buffer IsNot Nothing Then
        Response.ContentType = "application/pdf"
        Response.AddHeader("content-length", buffer.Length.ToString())
        Response.BinaryWrite(buffer)
    End If
End If

1 个答案:

答案 0 :(得分:0)

您需要为要发送的文件类型设置正确的内容类型:

<强> .PPT

application/vnd.ms-powerpoint

<强> .PPTX

application/vnd.openxmlformats-officedocument.presentationml.presentation

有关详情,请参阅Office MIME Types