Get a listing of files with WMI

C

CSharpWorker

Hi,
Can anyone point me to an example (in C#) of how to get a listing of files
from a remote machine using WMI & C#?
I have no problem using cross-domain log in and getting a list of processes
from the machine, and I've found how to get a list of directories on the
machine - I just can't seem to find how to get the files and file information
from a specific directory on the machine.

Really appreciate your help.
 
P

Peter Duniho

CSharpWorker said:
Hi,
Can anyone point me to an example (in C#) of how to get a listing of files
from a remote machine using WMI & C#?
I have no problem using cross-domain log in and getting a list of processes
from the machine, and I've found how to get a list of directories on the
machine - I just can't seem to find how to get the files and file information
from a specific directory on the machine.

Can you be more specific? What is it about the Directory.GetFiles()
method that isn't appropriate for your specific needs? Why does WMI
have to be part of the solution?

Pete
 
C

CSharpWorker

Thank you for your response Peter.
I've been told that I need to user WMI because I'm doing a cross-domain log
in and will need to check the files in the chosen directory to see if their
process is running. If the process is running, I need to be able to kill it -
if needed.
Can you recommend a different approach?

-Max
 
P

Peter Duniho

CSharpWorker said:
Thank you for your response Peter.
I've been told that I need to user WMI because I'm doing a cross-domain log
in and will need to check the files in the chosen directory to see if their
process is running. If the process is running, I need to be able to kill it -
if needed.
Can you recommend a different approach?

Different from what?

You might need WMI to actually connect to the remote share. But
otherwise, the Directory class should still work fine, once you're
connected.

As for process management, it will depend on your privileges and the
target OS, but the System.Diagnostics.Process class has the capability
of examining and managing the running processes on a remote machine.
So, I would start there. If that doesn't work for you, you might well
need to use WMI for that too.

Pete
 
C

CSharpWorker

Ok, thanks Pete. I'll work it out from there.

Peter Duniho said:
Different from what?

You might need WMI to actually connect to the remote share. But
otherwise, the Directory class should still work fine, once you're
connected.

As for process management, it will depend on your privileges and the
target OS, but the System.Diagnostics.Process class has the capability
of examining and managing the running processes on a remote machine.
So, I would start there. If that doesn't work for you, you might well
need to use WMI for that too.

Pete
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top