Excessive memory consumption using Filestream

Unanswered Excessive memory consumption using Filestream

  • 2006年3月9日 20:37
     
     

    Hi,

     

    I am writing jpg images from a file into a datatable. There are about three images in the target file , with a size of no more than 850kb per image. Yet this process seems to consume an inordinate amount of memory.

     

    Is there a better way?   

     

    Dim File As FileInfo

     

            Dim folder As New DirectoryInfo(FileLocation)

     

            For Each File In folder.GetFiles()

                Dim Row As Data.DataRow

                Row = DataTble.NewRow

     

                Dim Fs As FileStream = New FileStream(File.FullName, FileMode.Open, FileAccess.Read)

     

     

                Dim ImageData As Byte()

                ReDim ImageData(Fs.Length)

     

                Fs.Read(ImageData, 0, System.Convert.ToInt32(Fs.Length))

     

                Fs.Close()

     

                Row.Item(1) = ImageData

                DataTble.Rows.Add(Row)

            Next

     

    Any help with code samples will be greatly appreciated.

     

    Regards

     

    Andy