Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > deleting file referenced from gridview???

Reply
Thread Tools

deleting file referenced from gridview???

 
 
Bandit
Guest
Posts: n/a
 
      03-08-2005
I'm populating a gridview (called docList) with document info from a
network folder like so:

Sub Show_Files(ByVal inputDir As String)
Dim strFileNamePath As String = inputDir
Dim dirInfo As DirectoryInfo = New DirectoryInfo(strFileNamePath)
Dim aFiles As FileInfo() = dirInfo.GetFiles("*.doc")
Array.Sort(aFiles, New CompareFileInfoEntries
(CompareByOptions.LastWriteTime))
docList.DataSource = aFiles
docList.DataBind()
End Sub

This works fine and the gridview shows all files in the folder with a
command button for deleting. However when I try to delete a file like so:

Sub Row_Deleting(ByVal Src As Object, ByVal Args As
GridViewDeleteEventArgs)
If File.Exists(e.Keys("Name").ToString) Then
File.Delete(e.Keys("Name").ToString)
End If
End Sub

I get the following message:

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not
set
to an instance of an object.

Source Error:

Line 25:
Line 26: Sub Row_Deleting(ByVal Src As Object, ByVal Args As
GridViewDeleteEventArgs)
Line 27: If File.Exists(Args.Keys("Name").ToString) Then
Line 28: File.Delete(Args.Keys("FullName").ToString)
Line 29: End If

This is driving me nuts, I've tried everything I know to try and get a
file name from the GridViewDeleteEventArgs to delete the file but with no
success. Help!

Davy
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting data from the file without deleting the file first crea C++ 2 12-28-2012 11:50 PM
Callbacks when deleting self-referenced has_many? Sven S. Ruby 1 03-23-2010 09:29 AM
what is "Undefined first referenced symbol in file" Will hunting C++ 2 01-04-2007 01:46 PM
Accessing namespaces referenced in codebehind of an ascx file newjazzharmony@hotmail.com ASP .Net 2 05-23-2006 06:13 PM
Deleting a File from Hardrive and Deleting a SubKey in Registry Harry Barker C++ 2 04-19-2006 09:34 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57