TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
bijudaniel88
NA
1
0
how to solve this exception
May 23 2005 7:46 AM
Imports Leo_myfile Public Class Form1 Inherits System.Windows.Forms.Form For Each favfile In favfiles.temp <-------- I have a null exception here Dim item As New ListViewItem item.Text = favfile.Name item.SubItems.Add(favfile.size) lstfile.Items.Add(item) Next End Sub End Class ------------------------------------------------------------------------------------------------------------ imports System.IO Public Class mywebfile Public temp As webfilecollection Dim folder As String = "c:\temp1\" Public Sub scanfolder() scanfolder(folder) End Sub Public Sub scanfolder(ByVal folder As String) Dim folders As New DirectoryInfo(folder) Dim file As FileInfo For Each file In folders.GetFiles If String.Compare(file.Extension, ".*", True) = 0 Then Dim myfile As New webfile myfile.load(file) temp.add(myfile) End If Next End Sub End Class ------------------------------------------------------------------------------------------------------------ Public Class webfilecollection Inherits CollectionBase Public Sub add(ByVal favorite As webfile) list.Add(favorite) End Sub Public Sub remove(ByVal index As Integer) If index >= 0 And index < Count Then list.Remove(index) End If End Sub Public ReadOnly Property item(ByVal index As Integer) As webfile Get Return CType(list.Item(index), webfile) End Get End Property End Class ------------------------------------------------------------------------------------------------------------ mports System.IO Public Class webfile Public Name As String Public size As String Public Sub load(ByVal fileInfo As FileInfo) Name = fileInfo.Name Dim stream As New FileStream(fileInfo.FullName, FileMode.Open) Dim reader As New StreamReader(stream) Do While True Dim buf As String If buf Is Nothing Then Exit Do If buf.EndsWith("b") Then size = buf.Substring(0) Exit Do End If Loop reader.Close() stream.Close() End Sub End Class how to solve the null An unhandled exception of type 'System.NullReferenceException' occurred in fileviewer.exe Additional information: Object reference not set to an instance of an object. please help me
Reply
Answers (
3
)
DataGrid windows forms
How to: Turn hundreds of checkboxes into SQL update statement