Get a listing of files with WMI

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.

0
Utf
3/4/2010 10:17:01 PM
dotnet.languages.csharp 1931 articles. 0 followers. Follow

4 Replies
1908 Views

Similar Articles

[PageSpeed] 20

CSharpWorker wrote:
> 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
0
Peter
3/5/2010 5:57:56 AM
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

"Peter Duniho" wrote:

> CSharpWorker wrote:
> > 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
> .
> 
0
Utf
3/5/2010 9:02:45 PM
CSharpWorker wrote:
> 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
0
Peter
3/6/2010 3:19:26 AM
Ok, thanks Pete. I'll work it out from there.

"Peter Duniho" wrote:

> CSharpWorker wrote:
> > 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
> .
> 
0
Utf
3/7/2010 10:58:01 PM
Reply:

Similar Artilces:

publisher did not recognize my files
after updating office 2000, I can no longer read my saved publications How to use Office programs with the Norton AntiVirus Office plug-in http://support.microsoft.com/kb/329820/en-us -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com http://officebeta.iponet.net/en-us/publisher/FX100649111033.aspx "bosshossmotorcycle" <bosshossmotorcycle@discussions.microsoft.com> wrote in message news:BA4DEA42-9ED4-4E5A-8BA0-F0D724EFCA90@microsoft.com... > after updating office 2000, I can no longer read my saved publications ...

Any implication onf sending e-mail to large number of contact lists ?
One of my customers would like to send e-mails to contact lists that belong to my internal users. Those contact lists would contain addresses for account at hotmail, yahoo, etc. Total number of contact lists would be 2,000. Any implication if I create a DL and put all those contact lists there ? Any problem performance or security wise ? The biggest performance issue would be expansion of those DLs; I don't know how heavily-used they are or what the topology is so it's hard to say what the impact would be on your organization. As far as ongoing (and automated) maintenance of larg...

Corrupted Personal.xls file in Excel 97 ??
Oops! This is a correction to the subject of my previous posting. Please excuse me. =========================================================== I am using Excel 97. As of a few days ago, every time I start Excel I get a dialogue box that says "Personal.xls is being modified by Milt" (that's me) and giving me three choices: (1) Open the Personal.xls as a Read Only file, (2) Notify me when it becomes available, (3) Cancel. No matter which choice I take, the same dialogue box appears the next time I start Excel. The only way I have found to stop getting that dialogue b...

I cant get my email through aol on outlook
I set up my accounts while using outlook but I cant send emails, or recieve any emails without going to other on line sites such as aol, hotmail, I have checked and re-checked but still unable to send or recieve any emails Need more info - what version of OUTLOOK ? This should work OK with any version. the AOL site gives help on how to do this showing you the names of your servers. It is IMAP mail. Hotmail is HTTP mail, and again the Hotmail site has help on how to do this. -- Laura Rooke MVP - Mobile Devices ...

Vlookups to Excel Version 3 files.
I use a system that on a daily basis creates an Excel version 3 file containing cost centers and their budgets. When I do vlookups from other Excel 97 files to this file it takes a long time for the sheet to calculate. If I save the Excel V3 file as Excel 97 its OK, and if the Excel V3 file is open before the 97 file its OK. I don't want to have to constantly save the V3 file as 97 (I may not be around to do that always) Does anyone know how to resolve this. Thanks Naz ...

creating tmp files
Have Excel 2000 whenever click on save file it creates tmp file too. How can I prevent excel from creating these temp files. Thanks Chandra You cant "chandrak@futaiusa.com" <anonymous@discussions.microsoft.com> wrote in message news:9a9701c4343c$e2f2c6a0$a401280a@phx.gbl... : Have Excel 2000 whenever click on save file it creates tmp : file too. How can I prevent excel from creating these temp : files. : Thanks : Chandra But accoding to documents on excel if the file is saved without error messages it renames the temp file with xls why do I still see the xls and tmp fi...

How do I delete a message in my outbox that contains a large file
I tried to send an email containing a large enclosure. Too large to send and now the message is stuck in my outbox. How do I delete the message? I have tried the normal route - cut, delete, but it stays in the outbox and slows down my send/receive capabilities "Lillian" <Lillian@discussions.microsoft.com> wrote in message news:C11E7BA3-C410-48CC-8B15-F6EA284665E7@microsoft.com... > I tried to send an email containing a large enclosure. Too large to send > and > now the message is stuck in my outbox. How do I delete the message? I > have >...

How can I get current cell row number
I need to reference the row value of the current cell in a worksheet function: = row() in VBA: activecell.row Hope this helps Rowan excelneophyte wrote: > I need to reference the row value of the current cell ...

Need help saving a file!
Well let me start off by saying that I feel lost using the Office 97 programs! I had to make a new resume so I got myself a template off of the site here. It opened up in publisher so that's where I created my resume. I've put a lot of time into it and now realize that I think I made a huge mistake! How the heck do I save it as a more "acceptable" file without screwing up the format??? (for uploading as an attachment) Or is that just not possible? I've tried saving it as a word document, but like I said, screws up the whole format. I'm really lost, don...

Sending files from Vista
Windows mail is my default mail client. But if I right click on a data or picture file from my desktop or other areas it wants to send it with Outlook instead of Windows Mail. What settings do I have to change to get windows mail to do all my mail sending in this manner? "Stumped" <Stumped@discussions.microsoft.com> wrote in message news:4C240124-48D3-4EAB-B63B-8A0B20505905@microsoft.com... > Windows mail is my default mail client. But if I right click on a data or > picture file from my desktop or other areas it wants to send it with > Outlook >...

Inbox- Missing files/folders
This is the second time this has happened, I wonder if anyone can help. > Without any warning all the files and sub folders under my Inbox in Outlook > Express disappear totally but files in the Sent, Outbox, Deleted folders etc are all okay. Can > anyone tell me where they went and how to get them back. > Cheers. Hello, Please take a look at the following article. 321505 OLEXP: Outlook Express E-Mail Messages Are Missing from the Inbox Folder http://support.microsoft.com/?id=321505 If you check inbox.dbx file and there is no content of previous mail items, then there is n...

File Formate
I have five Excel files which contain the records of my previous 4 years Business matters. Suddenly yesterday when I opned one of my files I received the following messege. --------------------------------------- The file is not in recognizable formate. if you know the file is from another program which is incompatible with Microsoft Excel, click Cancel, then open the file in its original application. If you want to open the file later in Microsoft Excel, save it in a format that is compatible, such as text format. If you suspect the file is damaged, click help for more information about...

File size limits and workarounds?
Hi All, I've run into the 2 gig file size limit on Outlook 2000 a couple times now. Is there a way to clean the files so I can avoid this in the future? The way I fixed things is that I deleted stuff, then made a new pst file and copied all the folders over to the new file. I went from just over 2gig to 1.3 gigs. I've done this once before I think, so I know I'll hit it again. Just wondering how to avoid all this. Thanks, me Maybe use the Archive options? But remember an archive has the same size limitation, so at some point you would need to create a new Archive fil...

Can't delete file in Outlook express outbox
I have a large email file in my outbox that won't send and I can' delete it -- PhoenixVP ----------------------------------------------------------------------- PhoenixVPC's Profile: http://www.msusenet.com/member.php?userid=468 View this thread: http://www.msusenet.com/t-187101402 PhoenixVPC, you wrote on Fri, 26 Aug 2005 13:46:14 -0500: > I have a large email file in my outbox that won't send and I can't > delete it. Close Outlook Express and search for the file "Outbox.dbx" on your system. Delete it an restart OE. Best Regards Christian Goeller -...

Convert list of pairs [a(i),b(i)] to table that shows # of occurrences of each pair
Given something like this: apple,jan apple,feb apple,mar apple,jan apple,feb orange,jan orange,feb orange,jan orange,feb banana,jan banana,feb banana,mar banana,jan banana,feb I'd like to create a table that has three rows (the fruits) and three columns (the months). At the intersection of each row and column I'd like the number of occurrences of that particular fruit-month pair. Thanks for your time. Tom Z. Tom, Assume your data is in the range A1:A14, and you have a grid starting in cell C1 that looks like: C D E F 1 jan feb mar 2 apple 3 orange 4 banana ...

List a group of repeated data from sheet1 to sheet2 but not repeat
-- thadi I have one excel sheet1 look like the following. UserName Location Division Software Name Version Maria.Sigmund Parkade Probation Adobe Reader 7.0 Maria.Sigmund Parkade Probation Lotus Notes 6.5.5 Eric.Bell Parkade IT WebFldrs 1.0 Eric.Bell Parkade IT Adobe Reader 7.0 Eric.Bell Parkade IT Symantec AntiVirus 8.1 I want to modify this sheet1 to sheet 2 ...

Having some problems saving excel files
I had a Excel file that was worked on using a Office XP machine, and know it is back on my Mac. Know everytime I save I keep on getting this message everytime using Office 98 for Mac. "This file was created using a later version of Microsoft Excel. If you save this file using Microsoft excel 98, information created with features in the later version may be lost." I have tried the following. 1) Saving as a new file and renaming it 2) Saving as Excel 5.x, and then back to Excel 98 3) deleting the Cell comments that I created in Excel XP, and redoing them in Excel 98 Thank...

Importing CSV files into excel
Just a suggestion, but I don't see where anyone would ever want their imported data changed by default. How about having CSV files import to format TEXT by default and letting the user decide if he wants to make changes instead of making changes that cannot be undone by default. (the "general" formatting that changed all your numbers around) I've given up on using Excel to look at my data files that contain numbers, instead using wordpad and 3rd party freeware to edit data. Minutes instead of seconds to import a file that has dozens of columns of fixed width - lead...

Problem with Executable File generated using Debug Build
Hi All, I am facing a really wierd problem. I am working on a project in which I have implemeted a GUI for controlling laser microscopes. Everything was going fine till I added support for Filter Wheels. The program compiles perfectly fine. Runs perfectly fine if I run it using Microsoft Visual Studios. But When I try to run the program by double clicking on its icon in the debug folder, the program shows that main frame and then hangs. The problem was not there before I added the code for filter wheels. I am placed all the DLL files in the debug folder. Could any body help me out. Regard...

How do I get rid of the PERSONAL.XLS sheet from a workbook?
Everytime I want to "X" out of excel, I always have to also close the PERSONAL.XLS sheet Normally the Personal file is hidden If you use Windows | Hide then you will never need to close it again OR you could locate it in the XLSTART folder and just delete it - hope it has no macros that you need to use best wishes -- Bernard Liengme Microsoft Excel MVP http://people.stfx.ca/bliengme "Arencia" <Arencia@discussions.microsoft.com> wrote in message news:9E91F069-881E-4D83-A224-8B4E78365949@microsoft.com... > Everytime I want to "X" out of...

Can't get outlook Items to Sync with Handheld
I recently made some changes with some of the software I was using o my handheld and PC using outlook 2003. As a result I can no longe get outlook to sync with my Hand held. It synchronizes the syste info as well as avantgo etc, but as soon as it tries to syn calendar,contacts, tasks, or notes it just hangs there and eventuall I have to use the task manager to shut it down. It does not create new log file or summary so that I can see what happened. Has anyon else experienced this and found a solution Ott Otto Wenger <owenger@mchutchison-dot-com.no-spam.invalid> wrote: > I recentl...

Duplicate email to distribution list
Hello, I have created a distribution list with 82 contacts. When I send mail to this DL some recipients receive more than one mail, 2 or 3 copies of same mail. I'm sure that in DL there isn't double recipients! What Can I do? Outolook is 2003 and it is connected to Exchange 2003 server. Thx! simone.spasiano@gmail.com wrote: > Hello, I have created a distribution list with 82 contacts. When I > send mail to this DL some recipients receive more than one mail, 2 or > 3 copies of same mail. I'm sure that in DL there isn't double > recipients! What Can I do? Outolook ...

Installing Office 2007 and keep getting earlier fersion error
I have tried the uninstall utility in Windows XP for a trial version of Office 2003. The install of Office 2007 keeps telling me the 2003 version is still there. This is a multi-part message in MIME format. --------------040201090908050807090708 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit How long has it been since you installed Office 2003 "Trial Version"? Also please confirm that YOU REALLY MEAN OFFICE 2003 and not Office 2007. These are two different products doing almost identical things like writing a letter to ...

How to get Microsoft Outlook to cut and paste full email addresses
What is the switch that tells Microsoft Outlook to allow cut and pasting of email addresses? There MUST be a better way! When I copy and paste an email recipient from a name in outlook from list, I get the person's name and not their email address. Aaaaooooouuurrrrrrggggghhhh! The only way I know today to copy and paste the full email is to go to "view" "options" and then copy and paste from the "message options" header section. Geeeeeeeazus. Can Microsoft Outlook be this stuuuuuuuupid? There MUST be a better way to copy and paste Microsoft Outlook email ...

Name NOT Show in Global Address List
Hi all, I'm running SBS 2003 with exchange 2003 server. Recently, I hided one of the user on our exchange server so that the name won't show in the GAL. Now I'd like to show this person name on the GAL, but it's not showing up. I double checked to make sure the "hide from gal" is not check. What should I do? Please Help !! Thanks in advance, Ed Ed wrote: > Hi all, > > I'm running SBS 2003 with exchange 2003 server. Recently, I hided one > of the user on our exchange server so that the name won't show in the > GAL. Now I'd like to ...