Results 1 to 2 of 2

Thread: Invalid conversion from string [path to file] in Type Integer

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2015
    Posts
    1

    Exclamation Invalid conversion from string [path to file] in Type Integer

    Hello, i corrently working on an ModUpdater for an Arma3Mod

    Basicly it should download an RAR and unpack it... (Also keeping it Up2Date.. <-- Works)

    What doesnt work is the un-rar..

    Maybe one of you got an Idea..

    Code:
    Imports System
    Imports System.IO
    Imports System.ComponentModel
    Imports Microsoft.Win32
    Imports System.Diagnostics
    Imports System.Int64
    Imports System.IO.***********Exception
    Public Class Form1
        Dim tRestant As Int64
        Dim tEcoule As Int64
        Dim TailleFichier As Int64 = 0
        Dim TailleFichier2 As Int64 = 0
        Dim seconde As Boolean = True
        Dim min As Int64 = 0
        Dim max As Int64 = 1
        Dim pbarvalue As Int64 = 0
        Dim directory As String = "nochange"
        Dim file As String
        Private Sub UnRar(ByVal filepath As String, ByVal WorkingDirectory As String)
    
            Dim objRegKey As RegistryKey
            objRegKey = Registry.ClassesRoot.OpenSubKey("WinRAR\Shell\Open\Command")
    
            Dim obj As Object = objRegKey.GetValue("")
    
            Dim objRarPath As String = obj.ToString()
            objRarPath = objRarPath.Substring(1, objRarPath.Length - 7)
    
            objRegKey.Close()
    
            Dim objArguments As String
            objArguments = " X " & " " & filepath & " " + " " + WorkingDirectory
    
            Dim objStartInfo As New ProcessStartInfo()
            objStartInfo.UseShellExecute = True
            objStartInfo.FileName = objRarPath
            objStartInfo.Arguments = objArguments
            objStartInfo.WindowStyle = ProcessWindowStyle.Hidden
            objStartInfo.WorkingDirectory = WorkingDirectory & ""
    
            Dim objProcess As New Process()
            objProcess.StartInfo = objStartInfo
            objProcess.Start()
    
        End Sub
        Private Sub FlatButton1_Click(sender As Object, e As EventArgs) Handles FlatButton1.Click
            FolderBrowserDialog1.ShowDialog()
            directory = FolderBrowserDialog1.SelectedPath
            My.Computer.FileSystem.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma")
            My.Computer.FileSystem.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\directory.a3", directory, False)
        End Sub
    
        Private Sub FlatButton5_Click(sender As Object, e As EventArgs) Handles FlatButton5.Click
            If My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\directory.a3") Then
                file = My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\directory.a3") & "\arma3.exe"
                Process.Start(file, (" -mod=\LauncherArma\@ProjectLife;\LauncherArma\@CBA_A3; -connect=5.231.193.132:2302"))
            Else
                MsgBox("Please specify the path to your ArmA III folder.", MsgBoxStyle.Critical, "Error")
            End If
    
        End Sub
        Private Sub FlatButton2_Click(sender As Object, e As EventArgs) Handles FlatButton2.Click
            If My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\size.txt") Or My.Computer.FileSystem.FileExists(My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\directory.a3") & "\Addon.rar") Then
                MsgBox("You have already downloaded the mod! Check if an update is available.", MsgBoxStyle.Exclamation, "Error")
            Else
                If directory = "nochange" Then
                    MsgBox("Please select the Arma 3 directory!", MsgBoxStyle.Critical, "Error")
                Else
                    tEcoule = 0
                    PictureBox1.Visible = False
                    FlatProgressBar1.Visible = True
                    FlatLabel1.Visible = True
                    FlatLabel2.Visible = True
                    FlatLabel3.Visible = True
                    Timer2.Start()
                    BackgroundWorker1.RunWorkerAsync()
                End If
            End If
        End Sub
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            If My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\directory.a3") Then
                directory = My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\directory.a3")
            Else
                MsgBox("Please select your Arma III directory first!", MsgBoxStyle.Information, "Important")
            End If
        End Sub
    
        Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
            Dim FichierInfo As System.IO.FileInfo = New System.IO.FileInfo(My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\directory.a3") & "\Addon.rar")
            Dim TailleFichier As Int64 = FichierInfo.Length
            Dim size As Int64 = My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\size.txt")
            pbarvalue = TailleFichier / size * 100
            FlatProgressBar1.Value = pbarvalue
            If pbarvalue = 100 Then
                FlatButton6.Visible = True
                Timer3.Stop()
                Timer1.Stop()
                MsgBox("Please Install the Files now.", MsgBoxStyle.Information, "Ready to Install")
    
            End If
        End Sub
    
        Private Sub FlatButton4_Click(sender As Object, e As EventArgs) Handles FlatButton4.Click
            If My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\version-OLD.txt") Then
                My.Computer.Network.DownloadFile("ftp://altis:life@5.231.193.132:22/version.txt", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\version.txt")
                If My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\version.txt") = My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\version-OLD.txt") Then
                    My.Computer.FileSystem.DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\version.txt")
                    MsgBox("No updates are available", MsgBoxStyle.Information, "Addons Update")
                ElseIf My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\version.txt") <> My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\version-OLD.txt") Then
                    My.Computer.FileSystem.DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\version-OLD.txt")
                    My.Computer.FileSystem.RenameFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\version.txt", "version-OLD.txt")
                    My.Computer.FileSystem.DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\size.txt")
                    My.Computer.FileSystem.DeleteFile(My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\directory.a3") & "\Addon.rar")
                    tEcoule = 0
                    PictureBox1.Visible = False
                    FlatProgressBar1.Visible = True
                    FlatLabel1.Visible = True
                    FlatLabel2.Visible = True
                    FlatLabel3.Visible = True
                    Timer2.Start()
                    BackgroundWorker1.RunWorkerAsync()
                End If
            Else
                MsgBox("Please download the newest Version of the Mod.", MsgBoxStyle.Exclamation, "Error")
            End If
        End Sub
    
        Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
            Timer1.Start()
            Timer3.Start()
            Timer2.Stop()
        End Sub
    
        Private Sub BackgroundWorker1_DoWork(sender As Object, e As DoWorkEventArgs) Handles BackgroundWorker1.DoWork
            My.Computer.Network.DownloadFile("ftp://altis:life@5.231.193.132:22/size.txt", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\size.txt")
            My.Computer.Network.DownloadFile("ftp://altis:life@5.231.193.132:22/Addon.rar", My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\directory.a3") & "\Addon.rar")
            If My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\version.txt") Then
            ElseIf My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\version-OLD.txt") Then
                My.Computer.FileSystem.DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\version-OLD.txt")
            End If
            My.Computer.Network.DownloadFile("ftp://altis:life@5.231.193.132:22/version.txt", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\version-OLD.txt")
        End Sub
    
        Private Sub Timer3_Tick(sender As Object, e As EventArgs) Handles Timer3.Tick
            Dim size As Int64 = My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\size.txt")
            tEcoule += 1
            FlatLabel1.Text = "Time Passed : " & tEcoule & " sec"
            If seconde = True Then
                Dim FichierInfo As System.IO.FileInfo = New System.IO.FileInfo(My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\directory.a3") & "\Addon.rar")
                TailleFichier = FichierInfo.Length
                FlatLabel3.Text = "Download Speed :" & (TailleFichier - TailleFichier2) / 1000 & " (MB/s)"
                tRestant = (size - TailleFichier) / (TailleFichier - TailleFichier2)
                seconde = False
            ElseIf seconde = False Then
                Dim FichierInfo As System.IO.FileInfo = New System.IO.FileInfo((My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\directory.a3") & "\Addon.rar"))
                TailleFichier2 = FichierInfo.Length
                FlatLabel3.Text = "Download Speed : " & (TailleFichier2 - TailleFichier) / 1000 & " (MB/s)"
                seconde = True
                tRestant = (size - TailleFichier) / (TailleFichier2 - TailleFichier)
            End If
            FlatLabel2.Text = "Time Remaining : " & tRestant & " sec"
        End Sub
    
        Private Sub FlatButton3_Click(sender As Object, e As EventArgs)
            MsgBox("Credits :" & vbNewLine & vbNewLine & "Project:Life Arma 3 Launcher" & vbNewLine & vbNewLine & "" & vbNewLine & vbNewLine & "--", MsgBoxStyle.Information, "Crédits")
        End Sub
    
        Private Sub FlatButton6_Click(sender As object, e As EventArgs) Handles FlatButton6.Click
            If My.Computer.FileSystem.DirectoryExists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\LauncherArma") Then
                My.Computer.FileSystem.DeleteDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\LauncherArma", FileIO.DeleteDirectoryOption.DeleteAllContents)
            End If
            If My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\modsname.txt") Then
                '   My.Computer.FileSystem.DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\modsname.txt")
            End If
            My.Computer.FileSystem.CreateDirectory(My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\directory.a3") & "\LauncherArma")
            UnRar(My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\directory.a3") & "\Addon.rar", Environment.GetFolderPath(My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\directory.a3") & "\LauncherArma"))
            Dim ligne As String
            My.Computer.Network.DownloadFile("ftp://altis:life@5.231.193.132:22/modsname.txt", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\modsname.txt")
            Dim sr As New StreamReader(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\modsname.txt")
            While sr.Peek <> -1
                ligne = sr.ReadLine()
                ' My.Computer.FileSystem.CopyDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\LauncherArma\" & ligne, directory & "\" & ligne, True)
            End While
            PictureBox1.Visible = True
            FlatButton6.Visible = False
            FlatProgressBar1.Visible = False
            FlatLabel1.Visible = False
            FlatLabel2.Visible = False
            FlatLabel3.Visible = False
        End Sub
    
        Private Sub PictureBox2_Click(sender As Object, e As EventArgs) Handles PictureBox2.Click
    
        End Sub
    
        Private Sub FlatLabel2_Click(sender As Object, e As EventArgs) Handles FlatLabel2.Click
    
        End Sub
    
        Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
            Process.Start("http://altis.paradox-network.de")
        End Sub
    
        Private Sub FlatLabel1_Click(sender As Object, e As EventArgs) Handles FlatLabel1.Click
    
        End Sub
    
        Private Sub FlatLabel3_Click(sender As Object, e As EventArgs) Handles FlatLabel3.Click
    
        End Sub
    
        Private Sub FlatProgressBar1_Click(sender As Object, e As EventArgs) Handles FlatProgressBar1.Click
    
        End Sub
    
        Private Sub FormSkin1_Click(sender As Object, e As EventArgs) Handles FormSkin1.Click
            FlatButton6.Visible = True
        End Sub
    
        Private Sub FlatButton3_Click_1(sender As Object, e As EventArgs) Handles FlatButton3.Click
            My.Computer.FileSystem.DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\size.txt",
            Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
            Microsoft.VisualBasic.FileIO.RecycleOption.DeletePermanently,
            Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)
            My.Computer.FileSystem.DeleteFile(My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\directory.a3") & "\Addon.rar",
            Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
            Microsoft.VisualBasic.FileIO.RecycleOption.DeletePermanently,
            Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)
        End Sub
    End Class

  2. #2
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,781

    Re: Invalid conversion from string [path to file] in Type Integer

    Maybe you can tell us where in the code the actual error is.......

    I would also guess you have not turned on OptionStrict/Explicit, check my signature.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width