abi
abi

Reputation: 819

How to know a new folder is created in a particular folder

I am developing a desktop application in C#. I have programmatically created a folder(say ABC) inside the Main folder in C drive in Windows. I want to know whether an user has created any new folder(by simply right clicking and creating new folder) inside ABC. If the user has created a new folder then I need to get the details of that folder like folder name and privacy too.

Thanks in advance!

Upvotes: 1

Views: 116

Answers (2)

Vland
Vland

Reputation: 4272

You can use DirectoryInfo to get the list of subfolder

DirectoryInfo dirInfo = new DirectoryInfo(@"c:\ABC");
DirectoryInfo[] subFolders = dirInfo.GetDirectories();

I'm not sure what you mean by privacy...

Upvotes: 1

kdh
kdh

Reputation: 937

You can get the subdirectories of a folder (in your example, the folder "ABC") as an array of strings by calling the method GetDirectories:

string[] subdirs = Directory.GetDirectories(@"C:\ABC");

Then, if you'd like, you can iterate through all of them:

foreach (string dir in subdirs)
    //dir is a path to a subdirectory

Don't forget the using statement!

using System.IO;

Upvotes: 1

Related Questions