Click here to Skip to main content
15,899,754 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

I am developing the application for windows mobile. I want to set the path. I am not able to use the function Setcurrentdirectory as I can use in Simple MFC application. Please advice me how to set the path and run a file in the perticular location in the folder in windows device application
Posted
Updated 1-Feb-12 3:43am
v2

1 solution

// I want to set the path

You could try to set it explicitly, for any file operation :) :
C++
class CPathHolder : public CString
{
public:
  CPathHolder() :
#ifdef UNDER_CE // or another of your mobile defines
  CString(_T("\\Work\\your_files\\")) {} // or another default for CE
#esle
  CString(_T("C:\\Work\\your_files\\")) {} // or another default for PC
#endif
}

/*global*/ CString& GetPathHolder()
{
  static CPathHolder cPathHolder;
  return cPathHolder;
}

/*global*/ CString& GetCurrentPath()
{
  return GetPathHolder();
}

/*global*/ void SetCurrentPath(const CString& cszNewPath)
{
  GetPathHolder() = cszNewPath;
}

void CYourApp::CYourApp()
{
  SetCurrentPath(
#ifdef UNDER_CE
    _T("\\Work\\PhotoViewer\\LastFiles\\")
#else
    _T("C:\\Work\\PhotoViewer\\LastFiles\\")
#endif
  );

  //...
}

void CYourApp::ShowPngFile(const CString& cszPngFileNameWithoutPath)
{
  CString cszFullFileName(GetCurrentPath() + cszPngFileNameWithoutPath);

  //...
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900