|
-
Nov 28th, 2011, 04:00 AM
#5
Re: Remove temp document
 Originally Posted by .paul.
yes you're correct. it would've helped to know you're using .net 2.0
vb Code:
Public Class Form1 Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Dim temp As New List(Of String)(IO.Directory.GetFiles("X:\Documents and Settings\XXX\Desktop\vvvvv", "*.doc")) temp.RemoveAll(AddressOf isTemp) End Sub Private Function isTemp(s As String) Return IO.Path.GetFileName(s).StartsWith("~$") End Function End Class
Thanks Paul 
That worked. I have added to get the FileName as I was trying check whether the FullPath is starting with "~$".
vb.net Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim temp As New List(Of String)(IO.Directory.GetFiles("X:\Documents and Settings\XXX\Desktop\vvvvv", "*.doc")) temp.RemoveAll(AddressOf isTemp) For i As Integer = 0 To temp.Count - 1 ListBox1.Items.Add(temp.Item(i)) Next End Sub Private Function isTemp(ByVal s As String) Return IO.Path.GetFileName(s).StartsWith("~$") End Function

Edit:
I didn't saw that you have edited the code.
Last edited by akhileshbc; Nov 28th, 2011 at 04:02 AM.
Reason: didn't saw the "GetFileName" edit
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|