Solved

Deleting files

Posted on 1998-07-17
16
141 Views
Last Modified: 2010-05-03
Using a cmd button "delete" I want to place an (*) next to files that I will delete upon exiting my program.  After click on the "exit" command button all files marked with an asterik will be deleted and I will exit the program.  Can someone help me with this coding?
0
Comment
Question by:belk979
  • 5
  • 4
  • 3
  • +3
16 Comments
 

Author Comment

by:belk979
ID: 1466098
Adjusted points to 200
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1466099
Where is your file (in a list box, text box)?
How is your * added?

0
 

Expert Comment

by:davishahn
ID: 1466100
If you know the filename, simply use the Kill command against each file you have an astrisk by.
0
 

Author Comment

by:belk979
ID: 1466101
I need to know how to place the asterik "*" next to a file using a cmd button called "delete" (caption).  The files are located in a visual basic database.  Then I need to know how to delete all files marked with an asterik through an "exit" cmd button. (supply the code please.)
0
 

Expert Comment

by:davishahn
ID: 1466102
Be more specific about where your files are. What do you mean by 'located in a visual basic database'?
How are they being listed by your program?
Need more info to help.
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1466103
belk979,
Here is my idea. Sorry I did not have time to get to the code today. If not answered by Sunday, I will try.
Regards
Dalin

pull all the file name to a list box,
Add/remove the "*" in the front of the filename when the user click the filename.

In your exit cmd, loop through the items in the list,
If the first chr is "*" ( use the left function), then delete the file (use kill).
0
 

Expert Comment

by:davishahn
ID: 1466104
Be more specific about where your files are. What do you mean by 'located in a visual basic database'?
How are they being listed by your program?
Need more info to help.
0
 
LVL 1

Expert Comment

by:Staplehead
ID: 1466105
belk,

if you use a multi-select list box, then your users can ctrl-click to make multiple selections.  then, you can loop through the items in the list box, checking whether .Selected is true.  if it is, then delete the file.

larry
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:belk979
ID: 1466106
I created some files using visual basic. ("Add-in")
0
 

Expert Comment

by:davishahn
ID: 1466107
Are you talking about tables in an Access database?
0
 
LVL 3

Expert Comment

by:jjmartin
ID: 1466108
How are you showing this list of files?  Is it in a list box, database grid, what?  General questions get general answers, specific questions get specific answers.
0
 

Author Comment

by:belk979
ID: 1466109
In a database grid.
0
 
LVL 7

Accepted Solution

by:
kamall earned 200 total points
ID: 1466110
belk979,
Here is the answer:
This example will remove the selected filename from a list box (List1) when Command1 (caption= Delete) is clicked, and add it to another list box (List2) with an ' * ' to the left of the file name. Then when Command2 (caption=Exit) is clicked, a message box will apear showing you the files that will be deleted.
Just add 2 list boxes and to command buttons on your form and copy/paste the following code:

Private Sub Command1_Click()

List2.AddItem "*" & List1
List1.RemoveItem List1.ListIndex

End Sub

Private Sub Command2_Click()
   
    For x = 0 To List2.ListCount - 1
        MsgBox "File " & List2.List(x) & " will be deleted."
        'filename = Right$(List2.List(x), Len(List2.List(x)) - 1)
        'Kill filename
    Next
   
End Sub

Private Sub Form_Load()
    For x = 1 To 10
        List1.AddItem "File" & CStr(x) & ".xxx"
    Next
End Sub

To really delete the files, remove the ( ' ) from the two code lines in the Command2 procedure.

Hope that helps.
Regards
0
 
LVL 7

Expert Comment

by:kamall
ID: 1466111
One last thing,
In order to delete the files, they must be valid filenames including the full path of the files.
0
 

Author Comment

by:belk979
ID: 1466112
Thank You!
0
 
LVL 7

Expert Comment

by:kamall
ID: 1466113
You are welcome, belk979.
Have a nice day.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…

758 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

16 Experts available now in Live!

Get 1:1 Help Now