locked
Problem with File Open Dialog RRS feed

  • Question

  • Hello all,
    I want to use Open File Dialog ie GetOpenFileName api for 2 scenario :
    1) Trying to read a file from a particular directory.
    2) Saving a file to a particular directory
    But problem with GetOpenFileName api is that it opens the files/folders of My Documents folder only .Is it possible with this api that we can read/save a file from /to any folder ie can we traverse folders recursively.???
    Below i've given the relevant code snippt :
    OPENFILENAME    ofn;
    TCHAR    szFile[MAX_PATH] = TEXT("\0");
    memset( &(ofn), 0, sizeof(ofn));
    ofn.lStructSize    = sizeof(ofn);
    ofn.hwndOwner = hWnd;
    ofn.lpstrFile = szFile;
    ofn.nMaxFile = MAX_PATH;
    ofn.lpstrFilter = TEXT("All (*.*)\0*.*\0");   
    ofn.Flags = OFN_EXPLORER /* for reading file*/ OFN_PROJECT /*For saving file*/
    GetOpenFileName(&ofn);

    Could any one tell me where things gone wrong.

    Thanks in advance..
    Thursday, July 23, 2009 4:41 PM

Answers

  • Hi Umesh,

    I think,
    By default, the windows mobile application allow to open file from "My documents" only.
    The default path for saving file is under "My Documents".
    That's why, it won't allow to open file from other path.
    You can check behavior of other Windows Mobile application like: Word Mobile. It works same as we observed.
    If you want to open file from some other path, then you have to create your own Browse Folder dialog.
    I have done it in my application.

    Regards,
    Pariksheet.
    • Marked as answer by warrentang Monday, July 27, 2009 7:27 AM
    Friday, July 24, 2009 9:10 AM

All replies

  • Hi Umesh,

    If you use ofn.lpstrInitialDir = NULL;
    Then you can select file from root("\\") folder.

    Regards,
    Pariksheet.
    Friday, July 24, 2009 7:02 AM
  • Hello Pariksheet,
    Its not true in windows mobile pocket pc....
    I already checked it.
    Friday, July 24, 2009 8:28 AM
  • Hi Umesh,

    I think,
    By default, the windows mobile application allow to open file from "My documents" only.
    The default path for saving file is under "My Documents".
    That's why, it won't allow to open file from other path.
    You can check behavior of other Windows Mobile application like: Word Mobile. It works same as we observed.
    If you want to open file from some other path, then you have to create your own Browse Folder dialog.
    I have done it in my application.

    Regards,
    Pariksheet.
    • Marked as answer by warrentang Monday, July 27, 2009 7:27 AM
    Friday, July 24, 2009 9:10 AM