1.

Solve : Conversion from string to type 'Boolean' is not valid.?

Answer»

Im creating an uninstaller and i keep getting the following error "Conversion from STRING "C:\Pointblanc\Game" to type 'Boolean' is not valid." Any idea on whats gone wrong, here my script:
Code: [Select]Imports System.IO

Public CLASS FrmUninstall
Private Const m_cUNINSTALLDIRECTORY As String = "c:\Pointblanc"
Private Sub FrmUninstall_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim intFileCount As Integer
Dim intFolderCount As Integer
Dim intFileCounter As Integer
Dim intFolderCounter As Integer

Me.Show()
Me.Refresh()

With My.Computer.FileSystem

'Delete Files
intFileCount = .GetFiles(m_cUNINSTALLDIRECTORY).Count
intFolderCount = .GetDirectories(m_cUNINSTALLDIRECTORY).Count
ProgressBar1.Maximum = intFolderCount + intFileCount

If intFolderCount > 0 Then

intFolderCounter = 1

For Each Folder As String In .GetDirectories(m_cUNINSTALLDIRECTORY)
Dim FolderFoundInfo As New System.IO.DirectoryInfo(Folder)
InstallLog("Removing folder " & FolderFoundInfo.Name & " (" & intFolderCounter.ToString & " of " & intFolderCount.ToString & ")")
Directory.Delete(Folder, m_cUNINSTALLDIRECTORY & "\" & FolderFoundInfo.Name)
ProgressBar1.Value = ProgressBar1.Value + 1
lblPercent.Text = CStr(Fix(100 * intFolderCounter / intFolderCount)) & "%"
intFolderCounter = intFolderCounter + 1
Next
Else
MsgBox("There seems to be a foler(s) missing, PLEASE reinstall.")
End If

If intFileCount > 0 Then

intFileCounter = 1

For Each FileFound As String In .GetFiles(m_cUNINSTALLDIRECTORY)
Dim FileFoundInfo As New System.IO.FileInfo(FileFound)
InstallLog("Removing file " & FileFoundInfo.Name & " (" & intFileCounter.ToString & " of " & intFileCount.ToString & ")")
.DeleteFile(m_cUNINSTALLDIRECTORY & "\" & FileFoundInfo.Name)
ProgressBar1.Value = ProgressBar1.Value + 1
lblPercent.Text = CStr(Fix(100 * intFileCounter / intFileCount)) & "%"
intFileCounter = intFileCounter + 1
Next
Else
InstallLog("No files to copy.")
End If
End With
MsgBox("Uninstallation Complete")
Application.Exit()
End Sub


Private Sub InstallLog(ByVal strLog As String)
txtInstallLog.Text = txtInstallLog.Text & strLog & vbCrLf
txtInstallLog.SelectionStart = txtInstallLog.Text.Length

End Sub
End Class
Directory.Delete(Folder, m_cUNINSTALLDIRECTORY & "\" & FolderFoundInfo.Name)

See here

http://msdn.microsoft.com/en-us/library/fxeahc5f.aspx



Discussion

No Comment Found