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. Selection of lengthy path in the open save dialog box, retunr truncated string

Selection of lengthy path in the open save dialog box, retunr truncated string

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
5 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.
  • S Offline
    S Offline
    Sandeep Vaidya
    wrote on last edited by
    #1

    I have created the file open/save dialog box using CFile dialog. I selected the lengthy file path which is more than 512 bytes ( Jsapanese file path) the return value from the doModal() is IDOK. if I try to get the file name using the GetPathName(), it returns invalid truncated string. Please let me know any way to get whether the file path returned is truncated or how to get the correct full path. even the GetLastError() function return zero at tthis scenario. Thanks in advance sandeep

    N 1 Reply Last reply
    0
    • S Sandeep Vaidya

      I have created the file open/save dialog box using CFile dialog. I selected the lengthy file path which is more than 512 bytes ( Jsapanese file path) the return value from the doModal() is IDOK. if I try to get the file name using the GetPathName(), it returns invalid truncated string. Please let me know any way to get whether the file path returned is truncated or how to get the correct full path. even the GetLastError() function return zero at tthis scenario. Thanks in advance sandeep

      N Offline
      N Offline
      Nibu babu thomas
      wrote on last edited by
      #2

      What is the size fo the buffer that you passed? There is a member variable in the CFileDialog class called m_ofn which is an OPENFILENAME structure. Get hold of the lpstrFile and pass a TCHAR buffer that is enough to hold the file name.


      Nibu thomas Software Developer

      S 1 Reply Last reply
      0
      • N Nibu babu thomas

        What is the size fo the buffer that you passed? There is a member variable in the CFileDialog class called m_ofn which is an OPENFILENAME structure. Get hold of the lpstrFile and pass a TCHAR buffer that is enough to hold the file name.


        Nibu thomas Software Developer

        S Offline
        S Offline
        Sandeep Vaidya
        wrote on last edited by
        #3

        Yes I tried that by passing the maximum buffer, but still it return only truncated string. I looked into the implementation of the GetPathName() function and came to know that, it is returning only MAX_PATH. Current selected path is beyond the MAX_PATH. :(

        S 1 Reply Last reply
        0
        • S Sandeep Vaidya

          Yes I tried that by passing the maximum buffer, but still it return only truncated string. I looked into the implementation of the GetPathName() function and came to know that, it is returning only MAX_PATH. Current selected path is beyond the MAX_PATH. :(

          S Offline
          S Offline
          Sandeep Vaidya
          wrote on last edited by
          #4

          An update to my analyses is, it can return the file path upto 260 characters ( not bytes). If the selected path is beyond the 260 characters, it truncates. This scenario is possible when the folder path it self will be almost equal to 260 characters. Now if we select that folder from save as dialog to save some file, it truncates the path. Please le mt know whether I can change this to return me the full path. Thanks in advance Sandeep

          N 1 Reply Last reply
          0
          • S Sandeep Vaidya

            An update to my analyses is, it can return the file path upto 260 characters ( not bytes). If the selected path is beyond the 260 characters, it truncates. This scenario is possible when the folder path it self will be almost equal to 260 characters. Now if we select that folder from save as dialog to save some file, it truncates the path. Please le mt know whether I can change this to return me the full path. Thanks in advance Sandeep

            N Offline
            N Offline
            Nibu babu thomas
            wrote on last edited by
            #5

            UNICODE chars are two bytes long. So make sure you supply the required buffer for this purpose. If you are using MAX_PATH then use (MAX_PATH*2).


            Nibu thomas Software Developer

            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