Solved

Deleting Files

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

829 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