I am using the below sample to build a listview image gallery.
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/listviewsliderwindowrotator/defaultcs.aspx?product=listview
I am getting the Out of Memory exception. I have attached the code and error.
Would you please help me with this problem.
Imports System
Imports System.Collections.Generic
Imports System.Drawing.Imaging
Imports System.IO
Imports System.Linq
Imports System.Web
Imports System.Drawing
Imports System.Threading
Namespace Data
Public NotInheritable Class DataProvider
Private Sub New()
End Sub
<ThreadStatic()> Private Shared _photos As List(Of Photo)
Public Shared Function GetData() As IList(Of Photo)
If _photos IsNot Nothing Then
Return _photos
End If
_photos = New List(Of Photo)()
For Each file As String In Directory.GetFiles(HttpContext.Current.Server.MapPath("Res1\User1\Residence1\"))
Dim photo = New Photo()
photo.Name = Path.GetFileName(file)
Dim image__1 As Image = Image.FromFile(file)
Using memoryStream = New MemoryStream()
image__1.Save(memoryStream, ImageFormat.Png)
photo.Data = memoryStream.ToArray()
End Using
_photos.Add(photo)
Next
Return _photos
End Function
End Class
Public Class Photo
Private Shared ReadOnly _key As New Object()
<ThreadStatic()> Private Shared _counter As Integer
Public Sub New()
Id = GetId()
End Sub
Public Property Name() As String
Get
Return m_Name
End Get
Set(ByVal value As String)
m_Name = value
End Set
End Property
Private m_Name As String
Public Property Data() As Byte()
Get
Return m_Data
End Get
Set(ByVal value As Byte())
m_Data = value
End Set
End Property
Private m_Data As Byte()
Public Property Id() As Integer
Get
Return m_Id
End Get
Private Set(ByVal value As Integer)
m_Id = value
End Set
End Property
Private m_Id As Integer
Protected Shared Function GetId() As Integer
SyncLock _key
_counter += 1
End SyncLock
Return _counter
End Function
End Class
End Namespace