I've populated a DataGridView with the data from the PhishTank .CSV format database.
I now want to take a SPECIFIC cell set (the urls) and add them to a System.Collections.Specialized.StringCollection named PhishingURL
My code is as follows (im including the entire form code as it all interlinks):
Imports System.IO Imports LumenWorks.Framework.IO.Csv Imports System.Windows.Forms Public Class frmReader Private Sub ReadCsv() ' open the file "data.csv" which is a CSV file with headers Using csv As New CachedCsvReader(New StreamReader("verified_online.csv"), True) DataGridView1.DataSource = csv End Using End Sub Private Sub frmReader_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ReadCsv() End Sub Public Sub AddEntriesToSettings() Dim dvgRow As DataGridViewRow For Each dvgRow In DataGridView1.SelectedRows My.Settings.PhishingURL.Add(dvgRow.Cell("url").Value.ToString) Next My.Settings.Save() End Sub Private Sub btnCheckPhish_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheckPhish.Click Dim s As String For Each s In My.Settings.PhishingURL If txtPhishCheck.Text = s Then MessageBox.Show("One of the strings in the database was returned to be a phishing site.", "WARNING", MessageBoxButtons.OK, MessageBoxIcon.Information) End If Next End Sub Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGridView1.DataSourceChanged AddEntriesToSettings() My.Settings.Save() End Sub End Class
LumenWorks.Frameworks.IO.csv is the CSV interpretter in using - its quick - and loads 3933 entries in under 3 seconds. Good stuff xD
Im getting an "object reference not set to an instance of an object" error when i attempt to read from the settings file.
Im trying to read from the settings file as eventually this code will be integrated into Hyvar.NET (see Share your project forum - topic: Project Hyvar.NET), however i cant load from a datagridview that A) doesnt exist on the form, hasnt been populated because of 'A', and C) Its easier.
What exactly am i doing wrong, and could someone help me recode that?
Thanks in advance
That code is in my test project, frmReader doesnt actually exist in Hyvar.NET
This post has been edited by pryogene: 23 August 2009 - 01:09 PM