Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. File Dialog Issue

File Dialog Issue

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    marcomars
    wrote on last edited by
    #1

    Hello, I have a problem in my MFC project with a CFileDialog. I use it to open multiple files, just to get the files' size, and my code is something like this: CString str; POSITION pos; CFileDialog ldFile(TRUE,"avi", NULL, OFN_ALLOWMULTISELECT | OFN_HIDEREADONLY, "AVI Files (*.avi)|*.avi|All Files (*.*)|*.*||", this); int ret = ldFile.DoModal(); if(ret == IDOK) { pos = ldFile.GetStartPosition(); while(pos) { str = ldFile.GetNextPathName(pos); if (stat(str , &results) == 0) // The size of the file in bytes is in results.st_size files_size[files_count] = results.st_size; files_count++; } } What I observed is that I can open only a limited number of files (the number is smaller when files are larger): if I try anyway to load more files, no file is loaded and the function returns 2 instead of 1 as usual. Can anyone help me solve this issue? Thanks in advance, Marco.

    N 1 Reply Last reply
    0
    • M marcomars

      Hello, I have a problem in my MFC project with a CFileDialog. I use it to open multiple files, just to get the files' size, and my code is something like this: CString str; POSITION pos; CFileDialog ldFile(TRUE,"avi", NULL, OFN_ALLOWMULTISELECT | OFN_HIDEREADONLY, "AVI Files (*.avi)|*.avi|All Files (*.*)|*.*||", this); int ret = ldFile.DoModal(); if(ret == IDOK) { pos = ldFile.GetStartPosition(); while(pos) { str = ldFile.GetNextPathName(pos); if (stat(str , &results) == 0) // The size of the file in bytes is in results.st_size files_size[files_count] = results.st_size; files_count++; } } What I observed is that I can open only a limited number of files (the number is smaller when files are larger): if I try anyway to load more files, no file is loaded and the function returns 2 instead of 1 as usual. Can anyone help me solve this issue? Thanks in advance, Marco.

      N Offline
      N Offline
      Niklas L
      wrote on last edited by
      #2

      It's because the buffer used, CFileDialog::m_ofn.lpstrFile, is too small. Check out MSDN help and you'll get the idea how to solve this. (You'll have to allocate a larger buffer, and you can check exactly how large it needs to be)

      M 1 Reply Last reply
      0
      • N Niklas L

        It's because the buffer used, CFileDialog::m_ofn.lpstrFile, is too small. Check out MSDN help and you'll get the idea how to solve this. (You'll have to allocate a larger buffer, and you can check exactly how large it needs to be)

        M Offline
        M Offline
        marcomars
        wrote on last edited by
        #3

        thank you !!!!! :rolleyes: you sugestion was wery useful!!! Marco.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups