I have error 3 try to open any file in my application!

I'm trying to open files the issue is that the path or root directory
is not found
here some of code

if self.dlg.ShowModal() == wx.ID_OK:
            self.filename = self.dlg.GetFilename()
            self.dirname = self.dlg.GetDirectory()

            path = open(os.path.join(self.dirname, self.filename))
            self.file = editor.EditorPanel(self.mainntbk, -1)
            self.file.LoadFile(path.read())
            self.mainntbk.AddPage(self.file, ""+self.filename)
        self.dlg.Destroy()