Blupig
Feb 11th, 2011, 04:53 PM
This class, along with a few others prominent in my projects, crashes the VS IDE:
Public Class IO
Public Shared Function OpenString(ByVal FilePath As String) As String
Try
Dim objReader As New System.IO.StreamReader(FilePath)
Dim ret As String = objReader.ReadToEnd
objReader.Close()
Return ret
Catch ex As Exception
Return Nothing
End Try
End Function
Public Shared Sub SaveString(ByVal FilePath As String, ByVal SourceString As String)
On Error Resume Next
FileIO.FileSystem.WriteAllText(FilePath, SourceString, False)
End Sub
Public Shared Function FolderExists(ByVal FolderPath As String) As Boolean
Dim f As New System.IO.DirectoryInfo(FolderPath)
Return f.Exists
End Function
Public Shared Sub LoadList(ByRef ListObject As Object, ByVal FilePath As String)
Dim r As System.IO.StreamReader
r = New System.IO.StreamReader(FilePath)
While (r.Peek() > -1)
ListObject.Items.Add(r.ReadLine)
End While
r.Close()
End Sub
Public Shared Sub SaveList(ByVal ListObject As Object, ByVal FilePath As String)
Dim w As System.IO.StreamWriter
Dim i As Integer
w = New System.IO.StreamWriter(FilePath)
For i = 0 To ListObject.Items.Count - 1
w.WriteLine(ListObject.Items.Item(i))
Next
w.Close()
End Sub
Public Shared Sub ListFiles(ByRef L As Object, ByVal folderpath As String, Optional ByVal extension As String = "*.dll")
Try
Dim DirInfo As New DirectoryInfo(folderpath)
Dim FileInfoArray() As FileInfo = DirInfo.GetFiles(extension)
Dim FileInfo As FileInfo
Dim FileCount As Integer = 0
For Each FileInfo In FileInfoArray
FileCount = FileCount + 1
L.Items.Add(FileInfo.Name)
Next
Catch ex As Exception
ErrMsg()
End Try
End Sub
End Class
What the hell is wrong? I've tried just about everything from compatibility mode to admin to a couple registry edits...I've even reinstalled and am seriously considering a reformat. It does the same on my friend's VS. Apparently it's LoadList that does it in this particular class, but as I said before, a couple of my modules/classes in various other projects also pose the same issue, even without LoadList.
Sorry if this is the wrong section.
Public Class IO
Public Shared Function OpenString(ByVal FilePath As String) As String
Try
Dim objReader As New System.IO.StreamReader(FilePath)
Dim ret As String = objReader.ReadToEnd
objReader.Close()
Return ret
Catch ex As Exception
Return Nothing
End Try
End Function
Public Shared Sub SaveString(ByVal FilePath As String, ByVal SourceString As String)
On Error Resume Next
FileIO.FileSystem.WriteAllText(FilePath, SourceString, False)
End Sub
Public Shared Function FolderExists(ByVal FolderPath As String) As Boolean
Dim f As New System.IO.DirectoryInfo(FolderPath)
Return f.Exists
End Function
Public Shared Sub LoadList(ByRef ListObject As Object, ByVal FilePath As String)
Dim r As System.IO.StreamReader
r = New System.IO.StreamReader(FilePath)
While (r.Peek() > -1)
ListObject.Items.Add(r.ReadLine)
End While
r.Close()
End Sub
Public Shared Sub SaveList(ByVal ListObject As Object, ByVal FilePath As String)
Dim w As System.IO.StreamWriter
Dim i As Integer
w = New System.IO.StreamWriter(FilePath)
For i = 0 To ListObject.Items.Count - 1
w.WriteLine(ListObject.Items.Item(i))
Next
w.Close()
End Sub
Public Shared Sub ListFiles(ByRef L As Object, ByVal folderpath As String, Optional ByVal extension As String = "*.dll")
Try
Dim DirInfo As New DirectoryInfo(folderpath)
Dim FileInfoArray() As FileInfo = DirInfo.GetFiles(extension)
Dim FileInfo As FileInfo
Dim FileCount As Integer = 0
For Each FileInfo In FileInfoArray
FileCount = FileCount + 1
L.Items.Add(FileInfo.Name)
Next
Catch ex As Exception
ErrMsg()
End Try
End Sub
End Class
What the hell is wrong? I've tried just about everything from compatibility mode to admin to a couple registry edits...I've even reinstalled and am seriously considering a reformat. It does the same on my friend's VS. Apparently it's LoadList that does it in this particular class, but as I said before, a couple of my modules/classes in various other projects also pose the same issue, even without LoadList.
Sorry if this is the wrong section.