Solved

Delete Only specific  Cookies from Cookie Folder vb6

Posted on 2004-09-10
5
385 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
[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
  • 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 500 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

Technology Partners: 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!

Question has a verified solution.

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

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…
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 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…
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…
Suggested Courses
Course of the Month3 days, 21 hours left to enroll

630 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