none
[VB.NET] Space not managed by a Module RRS feed

  • Question

  • Hello,
    I created a program that updates another program's files (GTA5, FiveM) with a Mediafire download link.

    But the problem is that I have a TextBox with inside the directory that indicates or uncompress the update files for GTA5, but the problem is that in this directory there are spaces and it does not work.

    How to do it, because I tried to do in another directory but that does not have space and it works.
    Or else, I do not know how.
    Thank you

    I show code for Module_unrar.vb

    Module Module_unrar
        Sub UnRar(ByVal WorkingDirectory As String, ByVal filepath As String)
     
            ' Microsoft.Win32 and System.Diagnostics namespaces are imported
     
            Dim objRegKey As Microsoft.Win32.RegistryKey
            objRegKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey("WinRAR\Shell\Open\Command")
            ' Windows 7 Registry entry for WinRAR 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
            ' in the following format
            ' " X G:\Downloads\samplefile.rar G:\Downloads\sampleextractfolder\"
            objArguments = " X " & " " & filepath & " " + " " + WorkingDirectory
     
            Dim objStartInfo As New ProcessStartInfo()
            ' Set the UseShellExecute property of StartInfo object to FALSE
            ' Otherwise the we can get the following error message
            ' The Process object must have the UseShellExecute property set to false in order to use environment variables.
            objStartInfo.UseShellExecute = False
            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
    End Module

    And show code for form1

    Private Sub btnUnrar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUnrar.Click
           If TextBox1.Text = "" Or TextBox2.Text = "" Then
               MsgBox("Veuillez remplir toutes les cases demander pour le bon fonctionnement de la mise à jour", MsgBoxStyle.Critical, ("Erreur"))
           Else
               Module_unrar.UnRar(TextBox1.Text, "C:\UpdateXXXX\FiveM_Application_Data.rar")
               Module_unrar.UnRar(TextBox2.Text, "C:\UpdateXXXX\Grand_Theft_Auto_V.rar")
           End If
       End Sub


    Sunday, May 13, 2018 10:01 AM

Answers

  • Try adding quotation marks, probably here:

       objArguments = " X """ & filepath & """ """ & WorkingDirectory & """"


    • Marked as answer by theopom Sunday, May 13, 2018 10:21 AM
    Sunday, May 13, 2018 10:12 AM

All replies