DirectoryInfo and Network Shares

  • Thread starter Thread starter Charles Teel
  • Start date Start date
C

Charles Teel

I'm working on an app that will display a list of shared resources on
a PC connected to the TCP/IP network. I figured out how to get the
list of the shared folders and printers on a PC, but I can't figure
out how to differentiate between the two.

I'm using the DirectoryInfo.GetDirectories() method to get the list of
shared items (which returns the array of DirectoryInfo objects for the
shared items on the specified PC).

Any ideas?

Thanks in advance
 
Is this really a *Compact* Framework question? It sounds like you're
talking about desktop Windows. This group is about Windows CE/Windows
Mobile, *not* Windows XP/Windows Vista .NET...

Paul T.
 
Is this really a *Compact* Framework question?  It sounds like you're
talking about desktop Windows.  This group is about Windows CE/Windows
Mobile, *not* Windows XP/Windows Vista .NET...

Paul T.

Yes, this is a Compact Framework question, because the app is on a
Windows Mobile Device. Now, the PC that has the file and printer
shares is going to be a WinXP/Vista machine. But the code I'm writing
is on the mobile device.
 
OK. So you have a list of resources and the problem is to identify which
are printers and which are folders, yes? The underlying API for enumeration
of network resources is WNetEnumResource(). The structure returned by that
call includes a 'type' field which indicates either RESOURCETYPE_DISK or
RESOURCETYPE_PRINT. If the DirectoryInfo returns don't indicate a type, you
may have to P/Invoke directly to the WNet call to get the information. I'd
look at Attributes, but it's not clear whether that would tell you anything
or not.

Paul T.

Is this really a *Compact* Framework question? It sounds like you're
talking about desktop Windows. This group is about Windows CE/Windows
Mobile, *not* Windows XP/Windows Vista .NET...

Paul T.

Yes, this is a Compact Framework question, because the app is on a
Windows Mobile Device. Now, the PC that has the file and printer
shares is going to be a WinXP/Vista machine. But the code I'm writing
is on the mobile device.
 
At least on my CE5 device, DirectoryInfo doesn't indicate anything useful.
WNetEnumResources() gives the correct information for folders and printers.

Paul T.

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
 
And, as usual, OpenNETCF has the enumeration calls for WNet in the Smart
Device Framework.

Paul T.

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
At least on my CE5 device, DirectoryInfo doesn't indicate anything useful.
WNetEnumResources() gives the correct information for folders and
printers.

Paul T.

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
OK. So you have a list of resources and the problem is to identify which
are printers and which are folders, yes? The underlying API for
enumeration of network resources is WNetEnumResource(). The structure
returned by that call includes a 'type' field which indicates either
RESOURCETYPE_DISK or RESOURCETYPE_PRINT. If the DirectoryInfo returns
don't indicate a type, you may have to P/Invoke directly to the WNet call
to get the information. I'd look at Attributes, but it's not clear
whether that would tell you anything or not.

Paul T.



Yes, this is a Compact Framework question, because the app is on a
Windows Mobile Device. Now, the PC that has the file and printer
shares is going to be a WinXP/Vista machine. But the code I'm writing
is on the mobile device.
 
At least on my CE5 device, DirectoryInfo doesn't indicate anything useful.
WNetEnumResources() gives the correct information for folders and printers..

Paul T.

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT

Pinvoking WNetEnumResources() worked perfectly. Thanks!
 
Back
Top