Imports Microsoft.VisualBasic
Imports System.IO
Imports System.String

Public Class IsUploadImageAlreadyPersent

    Public Shared Function FileExists(ByVal FlName As String, ByVal strPath As String) As String
        Dim strFullPath As String
        Dim sPath As String
        sPath = strPath
        strFullPath = sPath & FlName
        HttpContext.Current.Trace.Warn("Full path=" & strFullPath)
        Dim fn As New FileInfo(strFullPath)
        Static strFName As String
        Dim strName As String
        Dim strExtension As String
        If fn.Exists Then
            ' fn.Delete()
            HttpContext.Current.Trace.Warn("Inside Function")

            strName = Mid(FlName, 1, FlName.LastIndexOf("."))
            strExtension = Mid(FlName, FlName.LastIndexOf(".") + 2, Len(FlName))

            strFName = strName & "_1." & strExtension
            HttpContext.Current.Trace.Warn("File Exists Changed Name =" & strFName)
            FileExists(strFName, sPath)
        Else
            HttpContext.Current.Trace.Warn("Else File Name -- >" & strFName)
            strFName = FlName
        End If
        FileExists = strFName
    End Function

End Class
