Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Delete Only specific  Cookies from Cookie Folder vb6

Posted on 2004-09-10
5
Medium Priority
?
388 Views
Last Modified: 2010-05-02
Hello Experts

I am trying to delete only specific cookies in my cookie folder

for example if i only want to delete   (   google.co[1].txt   ) in the cookie folder

Here is some more in my cookie folder

D:\Documents and Settings\Win2000\Cookies\win2000@www.cnn[1].txt
D:\Documents and Settings\Win2000\Cookies\win2000@google.co[1].txt
D:\Documents and Settings\Win2000\Cookies\win2000@experts-exchange[1].txt

I am using code in vb6

to display the cookies  folder in a listview1 box  i use the code.
'--------------------------------------------------------------------------------------
Private Sub Command1_Click()

   ListView1.ListItems.Clear
   
   Set FD = fso.GetFolder(Cookies)
    Set FLS = FD.Files
   
    For Each F In FLS
    ListView1.ListItems.Add , , "Item " & F.path  ' F.path contains the full path and name of cookie
    Next

End Sub
'--------------------------------------------------------------------------------------
and to select a  cookie in listview1  i am using
'--------------------------------------------------------------------------------------
Private Sub Command2_Click()

Dim intindex
 With ListView1
   For intindex = .ListItems.Count To 1 Step -1
      If .ListItems(intindex).Checked Then
          .ListItems.Remove intindex
      End If
   Next
 End With

End Sub

in the above code Command2_Click() how can i insert some code
to delete the actual cookie file selected  , for example if  ( google.co[1].txt  )  
is selected then i want to delete this cookie from the cookie folder

thanks experts






0
Comment
Question by:Jimmyx1000
  • 3
5 Comments
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 12030762
If you use the Microsoft Scripting runtime, you can use

Dim fs As New FileSystemObject
fs.DeleteFile FileName

Where FileName is the name of the file to delete.
0
 
LVL 14

Expert Comment

by:JohnK813
ID: 12030837
Give this a try.  Don't know if it's 100% accurate, though, so you'll have to test.

Dim cookie_name as String

...

      If .ListItems(intindex).Checked Then
          cookie_name = .ItemData(intindex)
          fso.DeleteFile cookie_name
          .ListItems.Remove intindex
      End If
0
 
LVL 14

Accepted Solution

by:
JohnK813 earned 2000 total points
ID: 12030858
Hmmm... looks like you add the word "Item " to the front of the cookie path/name.  So, you'll have to parse that out.

          cookie_name = .ItemData(intindex)
          cookie_name = Replace(cookie_name,"Item ","")
          fso.DeleteFile cookie_name
          .ListItems.Remove intindex
0
 

Author Comment

by:Jimmyx1000
ID: 12031242
Hello Experts

The command   " fso.DeleteFile cookie_name "
does not allow deleteing of the index.dat file in the cookie folder ,
 

how can i have the listview1 box stop from showing the line in listvew so it cant be checked
i would need to omit the listview  item which contain the words index.dat

i guess this would be in this code  

Private Sub Command1_Click()

   ListView1.ListItems.Clear
   
   Set FD = fso.GetFolder(Cookies)
    Set FLS = FD.Files
   
    For Each F In FLS
    ListView1.ListItems.Add , , "Item " & F.path  ' F.path contains the full path and name of cookie
    Next

End Sub
0
 
LVL 14

Expert Comment

by:JohnK813
ID: 12043620
You can do one of the following things:

'only add to listbox if filename contains ".txt"
    For Each F In FLS
      If Instr(F.path,".txt") then
         ListView1.ListItems.Add , , "Item " & F.path  ' F.path contains the full path and name of cookie
      End If
    Next


or:


'only add to listbox if filename does not contain "index.dat"
    For Each F In FLS
      If Not Instr(F.path,"index.dat") then
         ListView1.ListItems.Add , , "Item " & F.path  ' F.path contains the full path and name of cookie
      End If
    Next
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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

886 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