Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.IO
Public Partial Class _Default
Inherits System.Web.UI.Page
Private i As Integer = 0
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim s As Integer = fw1.FileName.LastIndexOf("."c)
Dim type As String = fw1.FileName.Substring(s)
Dim name As String = fw1.FileName.Substring(0, s)

bindname(name, name, type)
End Sub
Private Sub bindname(ByVal m As String, ByVal n As String, ByVal t As String)
If File.Exists(MapPath("pic\") + m + t) Then
i += 1
m = (n & "(") + i & ")"
bindname(m, n, t)
Else
fw1.PostedFile.SaveAs(MapPath("pic\") + m + t)
End If
End Sub
End Class