5 Replies - 301 Views - Last Post: 21 February 2019 - 03:27 AM Rate Topic: -----

#1 lukeman   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 23-January 19

Compare File Name Last Index and Copy Filename to Other Folder

Posted 20 February 2019 - 11:23 PM

I having trouble to compare the filename that I name it 'auto_1.exe', so when i upgrade the app and i rename it 'auto_2.exe'.
So, the greater filename i will copy and put on the desktop.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        FileCompare(filename:="stop")
    End Sub

    Private Sub FileCompare(filename As String)
        Dim FilePath As String()

        Dim status As String = ""
        FilePath = Directory.GetFiles("D:\LUQMAN\MyApp\Updater\", "*.exe")
        For Each file As String In FilePath
            If file = "" Then
                MessageBox.Show("not found")
            Else
                MessageBox.Show("found")
                Try
                    If filename.Length > 6 Then
                        Dim files As String = filename(6) '0 is the first index, 1 is the second, and so on...
                        Dim filed As String = IO.Path.GetFileName(files)
                        System.IO.File.Copy("D:\LUQMAN\MyApp\Updater\auto_2.exe", "C:\Users\Administrator\Desktop\MyProject\auto_2.exe")
                        MessageBox.Show("download success")
                    Else
                        MessageBox.Show("DLATEST VERSION")
                    End If

                Catch ex As Exception
                    MessageBox.Show(" error")
                End Try
            End If

        Next

    End Sub




I hope you can help me!!!

Is This A Good Question/Topic? 0
  • +

Replies To: Compare File Name Last Index and Copy Filename to Other Folder

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14925
  • View blog
  • Posts: 59,590
  • Joined: 12-June 08

Re: Compare File Name Last Index and Copy Filename to Other Folder

Posted 21 February 2019 - 01:03 AM

Try getting the file name without extension and then do a bit of string 'find' to get the _# value.

https://docs.microso...framework-4.7.2
Was This Post Helpful? 0
  • +
  • -

#3 lukeman   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 23-January 19

Re: Compare File Name Last Index and Copy Filename to Other Folder

Posted 21 February 2019 - 01:07 AM

how to compare the filename?
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14925
  • View blog
  • Posts: 59,590
  • Joined: 12-June 08

Re: Compare File Name Last Index and Copy Filename to Other Folder

Posted 21 February 2019 - 01:11 AM

You would know the incoming file name, right? You would know the number, right?

Get the existing file name, without extension, and then get the substring from the '_' to the end.. then you can compare numbers.
Was This Post Helpful? 0
  • +
  • -

#5 lukeman   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 23-January 19

Re: Compare File Name Last Index and Copy Filename to Other Folder

Posted 21 February 2019 - 02:17 AM

Can you give a code? I'm new in vb.net
Was This Post Helpful? 0
  • +
  • -

#6 andrewsw   User is offline

  • quantum multiprover
  • member icon

Reputation: 6775
  • View blog
  • Posts: 27,938
  • Joined: 12-December 12

Re: Compare File Name Last Index and Copy Filename to Other Folder

Posted 21 February 2019 - 03:27 AM

No, we don't just give code. We are here to assist and encourage. As you are new then you need to study the subject, getting some simple examples working, then making an attempt.

If you can provide a reasonable attempt at this, and/or ask a specific question, then we can assist you further.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1