# How to receive correct file and directory paths from user? [duplicate]

I want to receive import and export path from user. From this documentation I've known I can give the string property a sub-type which turns it to a file or directory selector, the problem is that they give a wrong path, some parts are replaced by ".." and some parts are not typed at all.

I want to receive those paths from user to use them later when the user executes an operator (by clicking a button when everything is ready).

this is my code:

class myPaths(bpy.types.PropertyGroup):
@classmethod
def register(cls):
bpy.types.Scene.myPaths = bpy.props.PointerProperty(type=myPaths)

@classmethod
def unregister(cls):
del bpy.types.Scene.myPaths

fileExportPath: StringProperty(
name="export path",
subtype="DIR_PATH",
description="some description"
)
jsonImportPath: StringProperty(
name="import path",
subtype="FILE_PATH",
description="path of .json file to import."
)
fileName:StringProperty(
name="output file name",
description="Write file name without any file extension."
)


How can I receive correct file and directory paths form user?

I found the solution here. use bpy.path.abspath(path) to get the absolute path to the file or directory.