Pramod Nandagiri
posted
201 posts
since
Jan 24, 2009
from
Hyderabad
|
|
Re: How to check a folder before deleting it using windows application ?
|
|
|
|
|
|
|
|
|
|
|
using System.IO;
button1_click { if(Directory.Exists("E:\\newfolder")) { Directory.Delete("E:\\newfolder",true); } }
... Please do not forget to mark the thread as "Accepted Answer" if if helps you...
|
|
|
|
|
|
Anjana Prasanth
posted
4 posts
since
Feb 21, 2012
from
Trivandrum
|
|
Re: How to check a folder before deleting it using windows application ?
|
|
|
|
|
|
|
|
|
|
|
Yes, its worked. But I want to check it before deleting and also want a message (Permission denied). Here the folder was not checked. Its simply deleted it.
|
|
|
|
|
|
Pramod Nandagiri
posted
201 posts
since
Jan 24, 2009
from
Hyderabad
|
|
Re: How to check a folder before deleting it using windows application ?
|
|
|
|
|
|
|
|
|
|
|
Hi, What do u want to check ,
Do you want to check whether folder has any files or sub directories then use
if(Directory.Exists("E:\\newfolder")) { try { Directory.Delete("E:\\newfolder"); // the above method deletes the newfolder only if it is empty } catch { MessageBox.Show("Permission Denied") } }
you should have to explain what do you want to check in folder clearly...
|
|
|
|
|
|
Anjana Prasanth
posted
4 posts
since
Feb 21, 2012
from
Trivandrum
|
|
Re: How to check a folder before deleting it using windows application ?
|
|
|
|
|
|
|
|
|
|
|
I want to delete a folder using file system watcher
|
|
|
|
|
|