Split multipage image into single page image in VB.Net

This code convert your multipage image into single image with new name.

First you Imports System.Drawing.Imaging in your project. Then on a button click event handler, write the following code. 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            'SplitImage(Image Path,Destination Path)
    SplitImage("D:\Fax\rraannaammeett.G3N", "D:\Amit\converted\")
End Sub

Private Function SplitImage(ByVal SourcePath As String, ByVal DestPath As String)
        
        'Dim FileSubString As String = System.IO.Path.GetFileNameWithoutExtension(files)

        'this code for get file/image name from path
        Dim Dir = SourcePath
        Dim path() As String = Dir.Split("\")
        Dim chunk As Integer = path.Length
        Dim ImageName As String = path(chunk - 1)
        ImageName = ImageName.Replace(".G3N", "")

        Dim pagecount, ImagePageCount As Integer
        Dim oimage As System.Drawing.Image = Nothing
        Dim fImage As Bitmap = Nothing
        Dim pageLoad As Boolean = False
        Dim docPath As String = DestPath
        Try
            fImage = New Bitmap(SourcePath, False)
            oimage = fImage
            pagecount = oimage.GetFrameCount(FrameDimension.Page)
            pageLoad = True
        Catch ex As Exception
            pageLoad = False
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
        If pageLoad = True Then
            If pagecount <> 0 Then
                For ImagePageCount = 0 To pagecount - 1
                    Dim strScanKey As String = System.Guid.NewGuid.ToString
                    oimage.SelectActiveFrame(FrameDimension.Page, ImagePageCount)
                    Dim img1 As Drawing.Bitmap = CType(oimage.Clone, Drawing.Bitmap)
                    Dim documentPath As String = docPath & ImageName & "_" & ImagePageCount + 1 & ".jpg"
                    img1.Save(documentPath)
                Next
            End If
            oimage.Dispose()
            fImage.Dispose()
        End If
End Function