Gets a Stream object that points to an uploaded file to prepare for reading the contents of the file.

Namespace:  EasyAlgo.EAUpload
Assembly:  EasyAlgo.EAUpload (in EasyAlgo.EAUpload.dll)
Version: 1.3.0.0

Syntax

C#
public Stream InputStream { get; }
Visual Basic (Declaration)
Public ReadOnly Property InputStream As Stream

Field Value

Type: System.IO..::.Stream
A Stream pointing to a file.

Examples

The following code example shows how to read the contents of the first file in the client's file collection into a byte array, and then copy the byte array to a string.
CopyC#
using System;
using System.Web;
using System.Web.UI;

using EasyAlgo.EAUpload

public class Page1: Page
{
    protected string MyString;
    private void Page_Load(Object sender, EventArgs e)
    {
        Upload _CurrentUpload = UploadsManager.GetUpload();
        UploadedFileCollection _FileCollection;
        UploadedFile _File;
        int FileLen;
        System.IO.Stream _Stream;

        _FileCollection = _CurrentUpload.UploadedFiles;
        _File = _FileCollection[0];

        FileLen = _File.ContentLength;
        byte[] input = new byte[FileLen];

        // Initialize the stream.
        _Stream = _File.InputStream;

        // Read the file into the byte array.
        _Stream.Read(input, 0, FileLen);

        // Copy the byte array into a string.
        for (int Loop1 = 0; Loop1 < FileLen; Loop1++)
            MyString = MyString + input[Loop1].ToString();

    }
}
CopyVB.NET
Imports System
Imports System.Web
Imports System.Web.UI

Public Class Page1: Inherits Page

 Protected Loop1 As Integer
 Protected MyString As String

  Protected Sub Page_Load(sender As Object, e As EventArgs)

    Dim _CurrentUpload As Upload = UploadsManager.GetUpload
    Dim _FileCollection As UploadedFileCollection
    Dim _File As UploadedFile
    Dim FileLen As Integer
    Dim MyString As String
    Dim _Stream As System.IO.Stream

    _FileCollection = _CurrentUpload.UploadedFiles
    _File = _FileCollection(0)

    FileLen = _File.ContentLength
    Dim Input(FileLen) As Byte

    ' Initialize the stream.
    _Stream = _File.InputStream

    ' Read the file into the byte array.
    _Stream.Read(input, 0, FileLen)

    ' Copy the byte array into a string.
    For Loop1 = 0 To FileLen-1
      MyString = MyString & Input(Loop1).ToString()
    Next Loop1

 End Sub

End Class

See Also