Click here to Skip to main content
15,919,613 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So i'm working on a FileExplorer Type thing in C# with more functionalities like renaming a bunch of files/folders, and i'm also providing the Basic Copy/Paste/Cut operations.

Now i'm working on the create new folder button And i want it to be windows-like

My code so far :
C#
int i = 0;
while (true)
 {
   string dirName = i == 0 ? System.IO.Path.Combine(txtCurrentPath.Text, "New Folder") : System.IO.Path.Combine(txtCurrentPath.Text, "New Folder (" + i + ")");
   if (!Directory.Exists(dirName))
    {
     Directory.CreateDirectory(dirName);
     break;
    }
      else
         i++;
}

Anyway my question is, How can i avoid all of that and just send a simple command or something like that to the explorer to use the built-in way of creating new folder.
i'm new to all this windows api and shell extension stuff, Thanks :)

What I have tried:

i googled and all that pops up is the C# way Directory.CreateDirectory(String DirName);
Posted
Updated 16-Apr-18 9:59am
v2

1 solution

Explorer does not expose API - it uses one... The Windows API for Directory management... The very same .NET's Directory wraps...
If you are going to create a richer file browser application it would be very unwise to bind it to an other application...
If you are interested to learn about the low level of the API check this: Directory Management Reference (Windows)[^], however do not hesitate to use .NET's classes to perform tasks, like creating a directory...
 
Share this answer
 
Comments
Member 13782733 16-Apr-18 16:40pm    
I wouldn't call that binding, if i'm just going to call a certain function, exactly like when you right click and choose new folder. right?
Dave Kreskowiak 16-Apr-18 19:57pm    
There's nothing to call. You just see if there is already any folders called some semblance of "New Folder", possibly with a number in parenthesis appended to it, create a new folder, calling it "New Folder" with the next number at the end, if required, adding the folder item to whatever you're using to display the folders, and force the item into edit mode.

There's nothing in Explorer to call.

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