Click here to Skip to main content
15,926,144 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi
I want to delete a folder in a remote machine in my winform program. Please help me, every idea is welcome, please say in detail.

Can I use WMI to run a remote file.bat to delete the folder. And if I can, how can i do it?

--thank you
Posted
Updated 28-Mar-12 2:14am
v2

Following code works for me:

C#
Directory.Delete(@"\\ip-adress-or-computer-name\path-to-folder");


For a description look here: Directory.Delete Method (String)

Of course, you need the right to delete a folder on the remote machine :)
 
Share this answer
 
Comments
dirk.zhang 28-Mar-12 8:12am    
thank you for answering me, but if the folder is auto create by server, I don't know the authority for me, but I know the administrator and his password.

Can I use something to run file.bat to delete it.
Andy411 28-Mar-12 10:11am    
Is your app running on the client and talking to a server? If so, why do you care about directories on the server? Is your app a kind of remote server tool?
dirk.zhang 28-Mar-12 21:18pm    
Because I want to clear the catalina in Tomcat folder
dirk.zhang 14-Apr-12 8:45am    
I also use your method, but you should use ".net user" to get right
I use WMI to remote file or folder
 
Share this answer
 
Comments
Serdar UZUN 4-Jun-14 6:54am    
You say WMI but HOW?
Bark Ups 20-Aug-14 17:49pm    
Read about WMI / Powershell and remote commands

some help can be found here --> http://blog.commandlinekungfu.com/2009/05/episode-31-remote-command-execution.html

regards

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900