h1.post-title { color:orange; font-family:verdana,Arial; font-weight:bold; padding-bottom:5px; text-shadow:#64665b 0px 1px 1px; font-size:32px; } -->

Pages

Increment File names If File already exists in Designation Path

Private Sub FileNameIncrement(SourcePath As String, DesignationPath As String)
    Dim dir As New DirectoryInfo(SourcePath)
    Dim fileName As String = dir.Name
    Dim fileNamewithoutExtension As String = Path.GetFileNameWithoutExtension(DesignationPath & "\" &
fileName)
    Dim fileExtention As String = Path.GetExtension(DesignationPath & "\" & fileName)
    Dim files As String() = Directory.GetFiles(DesignationPath)
    Dim count As Integer = files.Count(Function(file__1)
    Return file__1.Contains(fileName)
End Function)
    Dim newFileName As String = If((count = 0), fileName, [String].Format("{0} ({1})" & fileExtention, fileName,
count + 1))
    If File.Exists(DesignationPath & "\" & fileName) Then
        File.Copy(SourcePath, DesignationPath & "\" & newFileName)
    Else
        File.Copy(SourcePath, DesignationPath & "\" & fileName)
    End If
End Sub

Dim OutputPath As String = "C:\Documents and Settings\Naraayanan\My Documents\Downloads"
FileNameIncrement(textBox1.Text, OutputPath)

Increment File names If File already exists in C#.Net

private void FileNameIncrement(string SourcePath, string DesignationPath)
        {
            DirectoryInfo dir = new DirectoryInfo(SourcePath);
           
            string fileName = dir.Name;
            string fileNamewithoutExtension = Path.GetFileNameWithoutExtension(DesignationPath + "\\" + fileName);
            string fileExtention = Path.GetExtension(DesignationPath + "\\" + fileName);
            string[] files = Directory.GetFiles(DesignationPath);
            int count = files.Count(file => { return file.Contains(fileName); });
            string newFileName = (count == 0) ? fileName : String.Format("{0} ({1})" + fileExtention, fileName, count +

1);

            if (File.Exists(DesignationPath + "\\" + fileName))
            {
                File.Copy(SourcePath, DesignationPath + "\\" + newFileName);
            }
            else
            {
                File.Copy(SourcePath, DesignationPath + "\\" + fileName);
            }
        }

 string OutputPath = @"C:\Documents and Settings\Naraayanan\My Documents\Downloads";
            FileNameIncrement(textBox1.Text, OutputPath);

Check Input Value 0 To 4 in VB.Net

 Dim chk As Boolean
    Function IsChekcInputValue(ByVal number As Double) As Boolean
        If number = 0 Or number = 1 Or number = 2 Or number = 3 Or number = 4 Then
            Return True
        Else
            Return False
        End If
    End Function

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        For I As Integer = 0 To Trim(TextBox1.Text.Length) 
            chk = IsChekcInputValue(TextBox1.Text.IndexOf(I))
        Next
        If chk = False Then
            MsgBox("Please Enter 0 To 4 Numbers in Input Box")
        Else
            MsgBox("Thank U")
        End If
    End Sub

    Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If Char.IsNumber(e.KeyChar) = False Then
            e.Handled = True
        End If
    End Sub