# file browser by python in blender

I am having some problem in 'opening a file browser with python' in blender. Can you provide me with a sample code where I can access the file location after running from the script.

.

Please, if you have full code it will help me better. I am very new to python.

• You need to provide more context, is this part of an import operator, which invokes the file browser? Or a StringProperty(subtype='FILE_PATH') sitting in a panel? – CodeManX Jan 21 '15 at 9:22

I found this code sample (originally from the Blender wiki) to be very helpful in understanding file browser usage. Specifically, look at the "execute" method of the ScanFileOperator class, which passes self.filepath (the chosen file) to another function (scanFile):

#
#   Opens a file select dialog and starts scanning the selected file.
#
class ScanFileOperator(bpy.types.Operator):
bl_idname = "error.scan_file"
bl_label = "Scan file for return"
filepath = bpy.props.StringProperty(subtype="FILE_PATH")

def execute(self, context):
scanFile(self.filepath)
return {'FINISHED'}

def invoke(self, context, event):