How I can remove the filename in the path location?

I have textbox that show the path location.
During runtime My textbox show the full path location like this
c:\project\data\block\table.dbf.

How to remove the filename so that my textbox only show me path location like this

c:\project\data\block\

any suggestion or idea?