better way to retrieve file name

when using on both Windows and Unix-like systems, the original method would not be able to match the directory name due to different separators ('\' and '/')