|
|
|
start date: Thu, 23 Aug 2007 05:52:36 -0700,
posted on: microsoft.public.dotnet.languages.vb
back
| Thread Index |
|
1
cmdolcet69
|
|
2
unknown
|
Help with Deleting a file
I have the below code that calls a function to delete a file that i
added to a listview node. What happens is that that file doesn;t
delete. Please help me out. I have included the event handler and
function. Thanks
Private Sub btnDeleteReport_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnDeleteReport.Click
_partfile.Reports.RemoveReport(Me.tvAddedReports.Nodes(0).Nodes(0).Text,
Me.tvAddedReports.Nodes(0).Nodes(0).Nodes(0).Text)
End Sub
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Public Function RemoveReport(ByVal rPath As String, ByVal rPrinter As
String) As Integer
Try
Dim intloop As Integer
For intloop = 0 To reportArray.Count - 1
If CType(reportArray(intloop), Reports).ReportPath =
rPath And CType(reportArray(intloop), Reports).ReportPrinter =
rPrinter Then
reportArray.RemoveAt(intloop)
Exit For
End If
Next
Return 0
Catch ex As Exception
Return -1
End Try
End Function
Date:Thu, 23 Aug 2007 05:52:36 -0700
Author:
|
Re: Help with Deleting a file
On Aug 23, 8:52 am, cmdolcet69 wrote:
> I have the below code that calls a function to delete a file that i
> added to a listview node. What happens is that that file doesn;t
> delete. Please help me out. I have included the event handler and
> function. Thanks
>
> Private Sub btnDeleteReport_Click(ByVal sender As System.Object, ByVal
> e As System.EventArgs) Handles btnDeleteReport.Click
>
> _partfile.Reports.RemoveReport(Me.tvAddedReports.Nodes(0).Nodes(0).Text,
> Me.tvAddedReports.Nodes(0).Nodes(0).Nodes(0).Text)
>
> End Sub
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Public Function RemoveReport(ByVal rPath As String, ByVal rPrinter As
> String) As Integer
> Try
> Dim intloop As Integer
> For intloop = 0 To reportArray.Count - 1
> If CType(reportArray(intloop), Reports).ReportPath =
> rPath And CType(reportArray(intloop), Reports).ReportPrinter =
> rPrinter Then
> reportArray.RemoveAt(intloop)
> Exit For
> End If
> Next
> Return 0
> Catch ex As Exception
> Return -1
> End Try
> End Function
It appears to me that it only removes the entry for the file in the
list view. To actually delete the file I believe you will need to do
a:
System.IO.File.Delete("path to file")
Date:Thu, 23 Aug 2007 06:28:32 -0700
Author:
|
|
|