Link to home
Start Free TrialLog in
Avatar of Noggy
NoggyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

WinXPPro: Extracting "Offline Files" Info

I have thousands of files in my Offline File Cache (i.e. CSC or Offline Files Folder) and I want to be able to easily extract the details of what still needs to be synched. I know that I can do this in Explorer by viewing the Offline Files but this takes ages for it to refresh itself. Is there any way that I can extract this info in VB?

FYI The Shell32 API enables me to view a folder's Offline status (Shell32.Folder2.OfflineStatus) but this is rather pathetic. What I would like to do is extract the type of information that you can view in the Explorer window (e.g. Synchronization ["File is synchronized"; "Only local copy exists"], Availability etc).

I've also looked at WMI etc but I can't find anything there either.

Can anyone help? This is driving me nuts.
Avatar of zzzzzooc
zzzzzooc

Try the below. It'll enumerate through all items in "c:\windows\" and print (to debug) columns 0 and 1 (which, for that folder, are Name and Size). Different folders use different columns so you'll need to find the appropriate one for your properties.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/ifaces/ishelldetails/GetDetailsOf.asp

Form1:
---------------------------
'Project -> References... -> Microsoft Shell Controls and Automation (shell32.dll)
Option Explicit
Private Sub Form_Load()
    Dim objShell As New Shell
    Dim objFolder As Folder2, objFolderItem As FolderItem
    Dim strName As String, strSize As String
    Set objFolder = objShell.NameSpace("c:\windows\")
    If Not (objFolder Is Nothing) Then
        For Each objFolderItem In objFolder.Items
            strName = objFolder.GetDetailsOf(objFolderItem, 0)
            strSize = objFolder.GetDetailsOf(objFolderItem, 1)
            Debug.Print strName, strSize
        Next objFolderItem
    End If
End Sub
Avatar of Noggy

ASKER

Thanks zzzzzooc but I'm afraid that it doesn't work. I already had most of it (see code below), though I didn't have the GetDetailsOf line and it appears that the CSC folder is a Folder3 item and not a Folder2, which I had originally though:

Function fnOfflineStatusVB()
     Dim objShell As Shell
     Dim objFolder3 As Shell32.Folder3
     Dim objItem As Shell32.FolderItem
     Dim objShellItem As Shell32.ShellFolderItem
   
     Set objShell = New Shell
     Set objFolder3 = objShell.NameSpace("I:\CSC\")
   
     If (Not objFolder3 Is Nothing) Then
         'Dim nReturn
       
        For Each objItem In objFolder3.Items
            Set objItem = objItem
            Debug.Print objFolder3.GetDetailsOf(objItem, 0)
        Next objItem
         'nReturn = objFolder3.OfflineStatus
     End If
   
     Set objFolder3 = Nothing
     Set objShell = Nothing
End Function

A little look at the Locals window during debug shows that the IsBrowsable property is set to False. The MSDN article on this property doesn't say anything worthwhile either about possible ways to overcome it (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/objects/folderitem/isbrowsable.asp).

There has to be some way because Windows Explorer can do it somehow. Is there any way to screen-scrape Explorer? Although that would not be the ideal (or elegant) solution.
Avatar of Noggy

ASKER

By the way, I had already relocated my CSC folder to my I:\ drive; hence "I:\CSC\". It amazes me that Microsoft squirrel away what can become a very large folder under C:\Windows.
>> is a Folder3 item and not a Folder2
The object may support both interfaces for backwards-compatibility.

>>but I'm afraid that it doesn't work
Why doesn't it? What does "objFolder3.GetDetailsOf(objItem, 0)" return?

Btw, you don't require "Set objItem = objItem". The for/next iteration handles that for you.
Avatar of Noggy

ASKER

The objFolder3.GetDetailsOf(objItem, 0) does not return anything because there are no Items in the collection...probably because the folder is not browsable. So that line of code is not actually executed.

Yeah, the "Set objItem = objItem" used to be "Set objShellItem = objItem" while I was casting and playing around to see if the ShellItem would work at all. Alas no if the item collection isn't browsable. So, yes, I agree, this line of code is redundant; it's just one of those lines that will get tidied up once I find a way to get round this brick wall of a problem :-).
Suggestion: PAQ & Full Refund

>>DELETE this question
The information may be helpful to some. Although it may have not directly solved their issue, the logic is correct.

And my apologies for not replying, Noggy. I disabled any support for "offline browsing" so I couldn't further test to resolve your issue. That's the reason my proposed solution(s) weren't directed to the details of offline items.
Avatar of Noggy

ASKER

Thanks, zzzzzooc, for trying. It seems that there may be no solution to this problem. EE was my last port of call as I couldn't find anything on Google or MSDN. zzzzzooc, I shall post a separate "Points for zzzzzooc" question to give you some credit for the help you provided.

DanRollins - I agree with zzzzzooc that this q, although unanswered, could be of help to some people. Is it possible to just leave it open and not charge people for PAQ?

ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial