Solved

Deleting Files

Posted on 1998-10-06
1
126 Views
Last Modified: 2010-04-30
i have a file list box and made it so when you double click a file it deletes it it work good but only when in a directory like c:\stuff but if i am on on c:\ it gives the error cant find file because this line (Dir1.Path & "\" & File1.List(i) ) makes  it say C:\\ how can i fix this problem this is the complete code i am using
If File1.ListIndex <> -1 Then
For i = 0 To File1.ListCount - 1
If File1.Selected(i) Then Kill Dir1.Path & "\" & File1.List(i)
ProgressBar1.Max = File1.ListCount - 1
ProgressBar1.Value = i
Next i
End If
ProgressBar1.Value = 0
File1.Refresh
 thanks
0
Comment
Question by:440
1 Comment
 
LVL 12

Accepted Solution

by:
mark2150 earned 100 total points
ID: 1438519
You need to check to see if the rightmost char on the Dir1.Path is "\" and don't stick a 2nd one on if so.

work = Dir1.Path
if right( work, 1 ) <> "\" then work = work & "\"
work = work & File1.List(i)
If File1.Selected(i) Then Kill work


0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now