Solved

Deleting Files

Posted on 1998-10-06
1
124 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

760 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

18 Experts available now in Live!

Get 1:1 Help Now