Dim path As String = Nothing
Dim strDir = Nothing
Public Sub ImageFind()
If Directory.Exists("" & path & "" & ddlDir.Text) Then
Dim strImgUrl As String = "" & path & "" & ddlDir.Text & "\" & "Thumbnail.png"
If Not Directory.Exists(Server.MapPath("~/Themes/" & ddlDir.Text)) Then
Directory.CreateDirectory(Server.MapPath("~/Themes/" & ddlDir.Text))
End If
If File.Exists(strImgUrl) Then
If Not File.Exists(Server.MapPath("~/Themes/" & ddlDir.Text & /Thumbnail.png")) Then
Try
IO.File.Copy(strImgUrl, Server.MapPath("~/Themes/" & ddlDir.Text & "/Thumbnail.png"), True)
Catch ex As Exception
My.Response.Write(ex.Message)
End Try
End If
If File.Exists(Server.MapPath("~/Themes/" & ddlDir.Text & "/Thumbnail.png")) Then
Image1.ImageUrl = ("~/Themes/" & ddlDir.Text & "/Thumbnail.png")
Else
Image1.ImageUrl = Nothing
My.Response.Write("Thumbnail Not Found")
End If
Else
Image1.ImageUrl = Nothing
My.Response.Write("Can Not Find The 'Thumbnail.png' In The Specified Directry")
End If
Else
Image1.ImageUrl = Nothing
My.Response.Write("Can Not Find The Specified Directry")
End If
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Session("ID") = Nothing Then
My.Response.Redirect("~/Default.aspx")
Else
path = "C:\Users\Administrator\Documents\Visual Studio 2010\Projects\Restaurant Management System\Themes\"
If Directory.Exists(path) Then
strDir = IO.Directory.GetDirectories(path)
If ddlDir.Items.Count < 1 Then
For Each dirName As String In strDir
ddlDir.Items.Add(dirName.Split("\").Last)
Next
ImageFind()
End If
Else
My.Response.Write(" Path not Found")
End If
Literal1.Text = CStr(Session("ID"))
End If
End Sub
Protected Sub ddlDir_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlDir.SelectedIndexChanged
ImageFind()
End Sub
No comments:
Post a Comment