Hi,
Did you mean you drag a folder shortcut in the desktop directly to taskbar to pin it in the taskbar?
You just use this method for program to pin to taskbar. For Folder, please follow this steps:
1. Right-click or long-press on the empty space on the Desktop, then select
New and then Shortcut.
2. Click Browse and go to the folder you want, select it and click
OK.
3. Before you click Next, you will need to insert the word explorer, followed by a space before the folder's path(see screenshot below).

4. You'll then be asked to supply a name for this shortcut. Type in whatever you want and click
Finish. The folder shortcut will show up on your Desktop.
5. From there, it's a simple matter to drag and drop the shortcut to the taskbar. Or, if you prefer, you can right-click on the shortcut and choose "Pin to taskbar" from the menu that pops up(see screenshot).
