Solved

Deleting files

Posted on 1998-07-17
16
146 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
[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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…
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…

696 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