Solved

Deleting Files

Posted on 1998-10-06
1
129 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

691 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