Legge un documento word Try Dim stream As FileStream = File.Open("d:\word.doc", FileMode.Open) 'replace the location with your word doc. stream.Position = 0 ' Now read s into a byte buffer. Dim bytes() As Byte = New Byte(stream.Length) {} Dim numBytesToRead As Integer = CType(stream.Length, Integer) Dim numBytesRead As Integer = 0 While numBytesToRead > 0 ' Read may return anything from 0 to numBytesToRead. Dim n As Integer = stream.Read(bytes, numBytesRead, numBytesToRead) ' The end of the file is reached. If n = 0 Then Exit While End If numBytesRead += n numBytesToRead -= n End While stream.Close() Response.Clear() Response.ContentType = "application/word" Response.AddHeader("Content-disposition", "filename=output.doc") Response.OutputStream.Write(bytes, 0, bytes.Length) Response.OutputStream.Flush() Response.OutputStream.Close() Response.Flush() Response.Close() Catch ex As Exception Throw ex End Try |