Click here to Skip to main content
15,940,246 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a file in the below mentioned path.


My purpose is i want to delete file named 'rejection.doc' and folder '59225e54-4892-4ddc-8669-db47270645dd'.

Thanks in advance

What I have tried:

Updated 4-Apr-16 22:51pm

FileInfo fi = new FileInfo(path);
DirectoryInfo di = fi.Directory;

You should add error handing to this. Both FileInfo and DirectoryInfo classes have an "Exists()" method that should be checked.

The "true" in DirectoryInfo.Delete(true) says that the folder and contents should be deleted.
Share this answer
Try Directory.Delete:
string path = @"\\\Docs\DEV\417\59225e54-4892-4ddc-8669-db47270645dd\rejection.doc";
string containingFolder = Path.GetDirectoryName(path);
Directory.Delete(containingFolder, true);
Share this answer

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