I am currently maintaining a website that was developed using Visual Basic and my problem is that this web application I am currently maintaining or supporting has the following error.
Error 38 'DirList' is not a member of 'TigerBrandsIntranet.Lounge_Image_Library'. C:\Users\Wise\Desktop\Tiger(Intranet)\BackUp of TBIntranet\TBIntranet\Lounge\Image Library.aspx.vb 111 9 TigerBrandsIntranet
This is the code of the page that's giving me problems.
I would appreciate it so much if there's someone who can assist with this error.
Imports System.Drawing
Imports System.IO
Imports System.Drawing.Imaging
Partial Class Lounge_Image_Library
Inherits System.Web.UI.Page
Shared amsg As Label = New Label
Shared qmsg As Label = New Label
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
'Dim strStartPath As String
If Session("QuicklinksPath") = "" Then
Session("QuicklinksPath") = Server.MapPath("Image Library\")
End If
ListQuicklinks(Session("QuicklinksPath"))
If Session("ImagePath") = "" Then
Session("ImagePath") = Server.MapPath("Image Library\")
End If
If Request("imgdir") = "" Then
If Request("back") = "back" Then
If Session("strStartPath") = Session("ImagePath") Then
'do nor remove last dirname as we are at top level
Else
Dim spos, epos
epos = Len(Session("strStartPath"))
spos = InStrRev(Session("strStartPath"), "\", epos - 1)
Session("strStartPath") = Left(Session("strStartPath"), spos)
End If
Else
Session("strStartPath") = Server.MapPath("Image Library\")
End If
Else
If Request("menu") = "QM" Then
Session("strStartPath") = Session("ImagePath") & Request("imgdir") & "\"
Else
Session("strStartPath") = Session("strStartPath") & Request("imgdir") & "\"
End If
End If
ListFolder(Session("strStartPath"))
End Sub
Private Sub ListFolder(sFolderPath As String)
Dim DirNames, ilink As String
Dim cp
cp = 1
'start table
amsg.Font.Name = "Arial"
amsg.Font.Size = amsg.Font.Size.Small
amsg.Text = "<table width=100% cellspacing=4 cellpadding=4 >"
DirNames = Dir(sFolderPath, vbDirectory)
If Session("strStartPath") = Session("ImagePath") Then
Else
' write back
amsg.Text += "<tr><td colspan=2 >"
amsg.Text += "<a href=""Image Library.aspx?hdir=../&back=back"" style=""color:#000333;font-size:12px;text-decoration:none;""><<<<<< Back</a><br></td></tr>"
End If
Do While DirNames <> ""
If DirNames <> "." And DirNames <> ".." Then
If (GetAttr(sFolderPath & DirNames) And vbDirectory) = vbDirectory Then
'Session("strStartPath") = sFolderPath & DirNames
If cp = 1 Then
'begin new rol
amsg.Text += "<tr>"
'cp = cp + 1
End If
amsg.Text += "<td><a href=""Image Library.aspx?hdir=../&imgdir=" & DirNames & """ style=""color:#000333;font-size:12px;text-decoration:none;"">" & DirNames & "</a></td>" 'Print dir Folder Name
cp = cp + 1
Else
Dim image As System.Drawing.Image = System.Drawing.Image.FromFile(sFolderPath & DirNames)
Dim X As Integer = image.Width
Dim y As Integer = image.Height
Dim height As Integer = ((100 * y) / X)
Dim base64String As String
Using thumbnail As System.Drawing.Image = image.GetThumbnailImage(100, height, New System.Drawing.Image.GetThumbnailImageAbort(AddressOf ThumbnailCallback), IntPtr.Zero)
Using memoryStream As New MemoryStream()
thumbnail.Save(memoryStream, ImageFormat.Png)
Dim bytes As [Byte]() = New [Byte](memoryStream.Length - 1) {}
memoryStream.Position = 0
memoryStream.Read(bytes, 0, CInt(bytes.Length))
base64String = Convert.ToBase64String(bytes, 0, bytes.Length)
End Using
End Using
ilink = sFolderPath & DirNames
ilink = Replace(ilink, Server.MapPath("Image Library\"), "")
ilink = Replace(ilink, "\", "/")
If cp = 1 Then
'begin new rol
amsg.Text += "<tr>"
'cp = cp + 1
End If
amsg.Text += "<td><a href=""Image Library/" & ilink & """ target=_blank style=""color:#000333;font-size:12px;text-decoration:none;""><img border=0 align=middle src=""data:image/png;base64," & base64String & """> " & DirNames & "</a></td>"
cp = cp + 1
End If
If cp = 3 Then
'close ro
amsg.Text += "</tr>"
cp = 1
End If
End If
DirNames = Dir()
Loop
'close table
amsg.Text += "</table>"
Me.DirList.Controls.Add(amsg)
End Sub
Private Sub ListQuicklinks(sFolderPath As String)
Dim DirNames As String
qmsg.Font.Name = "Arial"
qmsg.Font.Size = amsg.Font.Size.Small
qmsg.Text = ""
DirNames = Dir(sFolderPath, vbDirectory)
Do While DirNames <> ""
If DirNames <> "." And DirNames <> ".." Then
If (GetAttr(sFolderPath & DirNames) And vbDirectory) = vbDirectory Then
qmsg.Text += "<tr>"
qmsg.Text += "<td class=""style70""> </td>"
qmsg.Text += "<td style=""background-image: url('../../Images/Dots_Underline.gif'); background-repeat: repeat-x; background-position: center bottom; padding-left:5px; class=""style64"">"
qmsg.Text += "<a title=""Go to the " & DirNames & " Page"" class=""Text"" href=""Image Library.aspx?hdir=../&menu=QM&imgdir=" & DirNames & """ target=""_self"" style=""color:#666666;font-size:11px;text-decoration:none;"">" & DirNames & "</a></td>"
qmsg.Text += "<td style=""background-image: url('../../Images/Dots_Underline.gif'); background-repeat: repeat-x; background-position: center bottom; padding-left:5px; "" >></td>"
qmsg.Text += "<td > </td>"
qmsg.Text += "<td rowspan=""3""> </td>"
qmsg.Text += "</tr>"
Else
End If
End If
DirNames = Dir()
Loop
Me.QMenu.Controls.Add(qmsg)
End Sub
Public Shared Function GetFilesRecursive(ByVal initial As String) As List(Of String)
' This list stores the results.
Dim result As New List(Of String)
' This stack stores the directories to process.
Dim stack As New Stack(Of String)
' Add the initial directory
stack.Push(initial)
' Continue processing for each stacked directory
Do While (stack.Count > 0)
' Get top directory string
Dim dir As String = stack.Pop
amsg.Text += "<a href=""Image Library.aspx?hdir=../&imgdir=" & dir & """ style=""text-decoration:none;"">" & dir & "</a><br>"
Try
' Add all immediate file paths
result.AddRange(Directory.GetFiles(dir, "*.*"))
' Loop through all subdirectories and add them to the stack.
Dim directoryName As String
For Each directoryName In Directory.GetDirectories(dir)
stack.Push(directoryName)
Next
Catch ex As Exception
End Try
Loop
' Return the list
Return result
End Function
Public Function ThumbnailCallback() As Boolean
Return False
End Function
End Class