How do I get a user defined filepath in Blender with python? I have to allow users of my addon to select a path via the directory browser window of blender.

Instead of using this 



I used Operator in panel to get the folder path from user as follows



I tried lot of ways and I referred this and still trying....

Here is my code, for operator to browser the folder and set it.

class OBJECT_OT_find(bpy.types.Operator):
bl_idname = "object.find"
bl_label = "Select Path "

directory = StringProperty(maxlen=1024, subtype='FILE_PATH', options={'HIDDEN', 'SKIP_SAVE'})
filter_image = BoolProperty(default=True, options={'HIDDEN', 'SKIP_SAVE'})
filter_folder = BoolProperty(default=True, options={'HIDDEN', 'SKIP_SAVE'})
filter_glob = StringProperty(default="", options={'HIDDEN', 'SKIP_SAVE'})

def execute(self, context):
    # what to write
    return {'FINISHED'}

def draw(self, context):
    self.layout.operator('file.select_all_toggle')        

def invoke(self, context, event):
    wm = context.window_manager
    wm.fileselect_add(self)
    return {'RUNNING_MODAL'}

def register():
 bpy.utils.register_class(OBJECT_OT_find)
 bpy.utils.register_module(__name__)
 bpy.types.Scene.FPath = StringProperty(name="Set Source to Find",
  attr="custompath",
  description="searching Images",
  maxlen= 1024,
  subtype='DIR_PATH',
  default= "")
def unregister():
 bpy.utils.register_class(OBJECT_OT_find)
 bpy.utils.unregister_module(__name__)
 del bpy.types.Scene.FPath


How can I get that path? I want to store and read it.
As far as I know, it's bad practice to create the custom property for the scene in the register function. You can do this in the execute function. Also you shouldn't create it on bpy.types.Scene but on the current scene itself.
For the execute function you can use this code:

def execute(self, context):
    d = self.properties.directory
    bpy.context.scene['image_filepath'] = d   #store the path for later use
    [...]
    return {'FINISHED'}


You only need the bpy.context.scene['image_filepath'] = d if you want to store the path for later use.

You can simplify your register and unregister functions:

def register():
    bpy.utils.register_module(__name__)

def unregister():
    bpy.utils.unregister_module(__name__)


You can now run your operator and choose a folder to do something with. If you later want to access the path to the folder you can use bpy.context.scene['image_filepath'].