So i have an SDI program that acts as a text editor. Just a program made from the appwizard. The problem is, how do i get the path where the document has been saved?
If You wish to know it only, it is easy: in Function CYourDoc::Serialize(CArchive& ar) You can get the Path+Name from ar.m_pFile->m_strFileName by saving.
After saving (not in Serialize()!) the Path and Name are in m_strPathName - Member of CYourDoc (it is the Class that appwizard has created for You).
If You wish change the name, it is not so easy - You must override for example BOOL CYourDoc:oSave(LPCTSTR lpszPathName, BOOL bReplace) Member.
1. If you open the document with the app you made then you can pull it from where you opened it.
I dont think this is where the problem is though. I would assume that you "save" the document with the app and need to save it again? If that is the case you can keep track of the path with the app. You can do this with a class or as mentioned above.
What I would also look into is CFileDialog which provides an easy interface to open and save/save as.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.