hi, due to my FTP server not liking to upload .exe files in order to get my auto updater to work i have to rename the folder .file before i upload
(example: C:/.../desktop/twijoo.exe.file)

after this is downloaded i need it to check the application folder for any files ending with ".file" and if it finds any to remove the ".file" so that it is just .exe

This is the code i have written so far...

If (Application.StartupPath + "\" + line).EndsWith(".file") Then
            Dim endsinnew As New TextBox
            endsinnew.Multiline = True
            endsinnew.Text = (Application.StartupPath + "\" + line).EndsWith(".file")
            Dim line2 As String = ""
            For Each line2 In endsinnew.Lines
                My.Computer.FileSystem.RenameFile(startup + "\" + line2, "????")
            Next

        End If

But i cannot work out how to just remove the .file from the end. It works if i specify a file but i cannot do this as i may need to download multiple files with the updater when it needs to update...

Hope that that is understandable and please help
thanks a lot
Matt ;)

PLease anyone?!
I need an answer so i can launch my program!

I'm not a super advanced coder so I'm sure there are more efficient ways of doing it but I would simply check if the name contains .exe and if it does add .file to the end of it.

Hope this is what you needed.

Public Sub RenameEXE(ByVal File As String)
        Dim EXE As Boolean = File.Contains(".exe")
        If EXE = True Then
            My.Computer.FileSystem.RenameFile(File, File & ".file")
        End If
    End Sub

Then do the same but backwards:

Public Sub RenameFILE(ByVal File As String)
        Dim FileExt As Boolean = File.Contains(".file")
        If FileExt = True Then
            My.Computer.FileSystem.RenameFile(File, File.Replace(".file", String.Empty))
        End If
    End Sub

Edited 6 Years Ago by Darkicon: n/a

Hi,

I'd be very cautious about letting anyone upload an exe file to my site. There is a reason the FTP server is blocking them...

That being said there's times you need to allow it too. I usually have a list of blocked extensions that I check before upload and if it is one of them, I ask the user to zip the file first. You don't want to just turn the file to a .exe without checking it out first.

dim BannedList as String =".exe,.vbs,.js"
...

if instr(BannedList, Myextension) <> 0 then
''show message
else
 'allow it
end if

Edited 6 Years Ago by G_Waddell: n/a

Thanks Dark Icon....
I think that would work!

BUT, every time i try to call it it says "argument not specified for parameter 'File' of public Sub RenameFILE(File As String)

Here is my whole code...

Public Class Form1

    Public Sub RenameFILE(ByVal File As String)
        Dim FileExt As Boolean = File.Contains(".file")
        If FileExt = True Then
            My.Computer.FileSystem.RenameFile(File, File.Replace(".file", String.Empty))
        End If
        MsgBox("hello!")
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim base As String = "http://twijoo.awardspace.info/Updater/"
        Dim startup As String = Application.StartupPath

        If (My.Computer.FileSystem.FileExists(startup + "\files.txt")) Then
            My.Computer.FileSystem.DeleteFile(startup + "\files.txt")
        End If

        My.Computer.Network.DownloadFile(base + "\files.txt", startup + "\files.txt")
        Dim todownload As New TextBox
        todownload.Multiline = True
        todownload.Text = My.Computer.FileSystem.ReadAllText(startup + "\files.txt")
        Dim line As String = ""
        Dim exename As String = Application.ExecutablePath.Remove(0, Application.ExecutablePath.LastIndexOf("\") + 1)
        For Each line In todownload.Lines

            If (line = exename) Then
                My.Computer.Network.DownloadFile(base + line, startup + "\" + line)
            Else
                If (My.Computer.FileSystem.FileExists(startup + "\" + line)) Then
                    My.Computer.FileSystem.DeleteFile(startup + "\" + line)
                End If
                My.Computer.Network.DownloadFile(base + line, startup + "\" + line)
            End If
        Next

        MsgBox("Download successful! Restarting the application!!!", MsgBoxStyle.Information)
        If (My.Computer.FileSystem.FileExists(Application.StartupPath + "\modding program.exe.old")) Then
            My.Computer.FileSystem.DeleteFile(Application.StartupPath + "\modding program.exe.old")
        End If

        If (My.Computer.FileSystem.FileExists(Application.StartupPath + "\modding program.exe")) Then
            My.Computer.FileSystem.RenameFile(Application.StartupPath + "\modding program.exe", "modding program.exe" + ".old")
        End If

        My.Computer.FileSystem.RenameFile(startup + "\" + "modding program.exe.new", "modding program.exe")

        Me.RenameFILE()

        Application.Exit()
    End Sub

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
    End Sub
End Class

It's because when you call RenameFile you have to specify an argument for the byval keyword, which would be the file or files (Do a For Each for multiple files) you want to rename. For example:

RenameFILE("C:\text.txt")

It's because when you call RenameFile you have to specify an argument for the byval keyword, which would be the file or files (Do a For Each for multiple files) you want to rename. For example:

RenameFILE("C:\text.txt")

i do not understand...
I am new to coding. If there any chance you could edit the post of my code that i made with it in the correct place? I think that this is the simplest method by which i will understand fully.

Thanks ;)

This question has already been answered. Start a new discussion instead.