Loading ...
Sorry, an error occurred while loading the content.

FileName Size?

Expand Messages
  • tonykoz
    When doing a FILEDIALOG, I just figured out that the name of the file cannot be larger than 127 bytes or you get an OS error. In my case, when I m navigating
    Message 1 of 5 , Oct 30, 2007
    • 0 Attachment
      When doing a FILEDIALOG, I just figured out that the name of the
      file cannot be larger than 127 bytes or you get an OS error.

      In my case, when I'm navigating my network, it is possible and
      likely that the returned string will be at least 128 bytes. Oops!!

      Here is what I was using to determine this.

      [loop]
      filedialog "Open text file", "*.txt", fileName$
      if fileName$="" then end
      print "File Name = ";fileName$
      print "Len = ";len(fileName$)
      goto [loop]

      By varying the size of a filename and selecting it, a len of 127
      passes, but 128 gives the following error:

      Runtime Error: The parameter is incorrect. ( OS Error 16r57). See
      the error.log file for more info.

      I'm running XP SP2 on several systems that all give the same error
      message.

      My workaround for now is to try to make the filename size smaller by
      moving the file to a location with a shorter path. Anything else I
      can do? Is this a known problem?

      Thanks,
      Tony
    • Harmon Vinson
      A search for your OS error number at MSDN came back with this page: http://msdn2.microsoft.com/en-us/library/aa365247.aspx Your OS should allow 255 character
      Message 2 of 5 , Oct 31, 2007
      • 0 Attachment
        A search for your OS error number at MSDN came back with this page:
        http://msdn2.microsoft.com/en-us/library/aa365247.aspx

        Your OS should allow 255 character filenames.
        Hmm, maybe this is an LB limit.
        A search at the LB conforums didn't reveal anything.

        --- In libertybasic@yahoogroups.com, "tonykoz" <tonyk73@...> wrote:
        > When doing a FILEDIALOG, I just figured out that the name of the
        > file cannot be larger than 127 bytes or you get an OS error.
        >
        > In my case, when I'm navigating my network, it is possible and
        > likely that the returned string will be at least 128 bytes. Oops!!
        >
        > Here is what I was using to determine this.
        >
        > [loop]
        > filedialog "Open text file", "*.txt", fileName$
        > if fileName$="" then end
        > print "File Name = ";fileName$
        > print "Len = ";len(fileName$)
        > goto [loop]
        >
        > By varying the size of a filename and selecting it, a len of 127
        > passes, but 128 gives the following error:
        >
        > Runtime Error: The parameter is incorrect. ( OS Error 16r57). See
        > the error.log file for more info.
        >
        > I'm running XP SP2 on several systems that all give the same error
        > message.
        >
        > My workaround for now is to try to make the filename size smaller by
        > moving the file to a location with a shorter path. Anything else I
        > can do? Is this a known problem?
      • tonykoz
        I suspect this is an LB issue since other Windows apps work fine with the large file name, although I have not tried to get close to the 255 char barrier. ...
        Message 3 of 5 , Nov 1, 2007
        • 0 Attachment
          I suspect this is an LB issue since other Windows apps work fine
          with the large file name, although I have not tried to get close to
          the 255 char barrier.

          --- In libertybasic@yahoogroups.com, "Harmon Vinson" <harmonv@...>
          wrote:
          >
          > A search for your OS error number at MSDN came back with this page:
          > http://msdn2.microsoft.com/en-us/library/aa365247.aspx
          >
          > Your OS should allow 255 character filenames.
          > Hmm, maybe this is an LB limit.
          > A search at the LB conforums didn't reveal anything.
          >
          > --- In libertybasic@yahoogroups.com, "tonykoz" <tonyk73@> wrote:
          > > When doing a FILEDIALOG, I just figured out that the name of the
          > > file cannot be larger than 127 bytes or you get an OS error.
          > >
          > > In my case, when I'm navigating my network, it is possible and
          > > likely that the returned string will be at least 128 bytes.
          Oops!!
          > >
          > > Here is what I was using to determine this.
          > >
          > > [loop]
          > > filedialog "Open text file", "*.txt", fileName$
          > > if fileName$="" then end
          > > print "File Name = ";fileName$
          > > print "Len = ";len(fileName$)
          > > goto [loop]
          > >
          > > By varying the size of a filename and selecting it, a len of 127
          > > passes, but 128 gives the following error:
          > >
          > > Runtime Error: The parameter is incorrect. ( OS Error 16r57).
          See
          > > the error.log file for more info.
          > >
          > > I'm running XP SP2 on several systems that all give the same
          error
          > > message.
          > >
          > > My workaround for now is to try to make the filename size
          smaller by
          > > moving the file to a location with a shorter path. Anything
          else I
          > > can do? Is this a known problem?
          >
        • Richard Russell
          ... Hopefully this is something which Carl can fix in a future version. Meanwhile you can use the code below as a substitute for FILEDIALOG; it works in a
          Message 4 of 5 , Nov 2, 2007
          • 0 Attachment
            --- In libertybasic@yahoogroups.com
            <mailto:libertybasic@yahoogroups.com> , "tonykoz" <tonyk73@...> wrote:
            > I suspect this is an LB issue since other Windows apps work fine
            > with the large file name

            Hopefully this is something which Carl can fix in a future version.
            Meanwhile you can use the code below as a substitute for FILEDIALOG; it
            works in a similar fashion but doesn't have the 128-character
            limitation. Change 'GetOpenFileNameA' to 'GetSaveFileNameA' if you want
            the 'save' version of the dialog.

            Richard.

            ' Code begins here
            sub NewFileDialog title$, template$, byref filepath$

            struct fs, lStructSize as ulong, hwndOwner as ulong, hInstance as ulong,
            _
            lpstrFilter as ptr, lpstrCustomFilter as ptr, nMaxCustFilter as ulong,
            _
            nFilterIndex as ulong, lpstrFile as ptr, nMaxFile as ulong, _
            lpstrFileTitle as ptr, nMaxFileTitle as ulong, lpstrInitialDir as ptr,
            _
            lpstrTitle as ptr, Flags as ulong, nFileOffset as ushort, _
            nFileEXtension as ushort, lpstrDefExt as ptr, lCustData as ulong, _
            lpfnHook as ulong, lpTemplateName as ulong

            title$ = title$ + CHR$(0)
            template$ = template$ + " files" + CHR$(0) + template$ + CHR$(0) +
            CHR$(0)
            tempfile$ = CHR$(0) + SPACE$(258) + CHR$(0)

            fs.lStructSize.struct = LEN(fs.struct)
            fs.lpstrFilter.struct = template$
            fs.lpstrFile.struct = tempfile$
            fs.lpstrTitle.struct = title$
            fs.nMaxFile.struct = 260
            fs.Flags.struct = 6

            calldll #comdlg32, "GetOpenFileNameA", fs as struct, ret as ulong
            if (ret) then
            filepath$ = Winstring(fs.lpstrFile.struct)
            else
            filepath$ = ""
            end if

            end sub




            [Non-text portions of this message have been removed]
          • tonykoz
            Thanks, this code works great. ... FILEDIALOG; it ... want ... ulong, ... ulong, ... as ptr, ... ulong, _
            Message 5 of 5 , Nov 5, 2007
            • 0 Attachment
              Thanks, this code works great.


              --- In libertybasic@yahoogroups.com, "Richard Russell" <yahoo@...>
              wrote:
              >
              >
              > --- In libertybasic@yahoogroups.com
              > <mailto:libertybasic@yahoogroups.com> , "tonykoz" <tonyk73@> wrote:
              > > I suspect this is an LB issue since other Windows apps work fine
              > > with the large file name
              >
              > Hopefully this is something which Carl can fix in a future version.
              > Meanwhile you can use the code below as a substitute for
              FILEDIALOG; it
              > works in a similar fashion but doesn't have the 128-character
              > limitation. Change 'GetOpenFileNameA' to 'GetSaveFileNameA' if you
              want
              > the 'save' version of the dialog.
              >
              > Richard.
              >
              > ' Code begins here
              > sub NewFileDialog title$, template$, byref filepath$
              >
              > struct fs, lStructSize as ulong, hwndOwner as ulong, hInstance as
              ulong,
              > _
              > lpstrFilter as ptr, lpstrCustomFilter as ptr, nMaxCustFilter as
              ulong,
              > _
              > nFilterIndex as ulong, lpstrFile as ptr, nMaxFile as ulong, _
              > lpstrFileTitle as ptr, nMaxFileTitle as ulong, lpstrInitialDir
              as ptr,
              > _
              > lpstrTitle as ptr, Flags as ulong, nFileOffset as ushort, _
              > nFileEXtension as ushort, lpstrDefExt as ptr, lCustData as
              ulong, _
              > lpfnHook as ulong, lpTemplateName as ulong
              >
              > title$ = title$ + CHR$(0)
              > template$ = template$ + " files" + CHR$(0) + template$ + CHR$(0) +
              > CHR$(0)
              > tempfile$ = CHR$(0) + SPACE$(258) + CHR$(0)
              >
              > fs.lStructSize.struct = LEN(fs.struct)
              > fs.lpstrFilter.struct = template$
              > fs.lpstrFile.struct = tempfile$
              > fs.lpstrTitle.struct = title$
              > fs.nMaxFile.struct = 260
              > fs.Flags.struct = 6
              >
              > calldll #comdlg32, "GetOpenFileNameA", fs as struct, ret as ulong
              > if (ret) then
              > filepath$ = Winstring(fs.lpstrFile.struct)
              > else
              > filepath$ = ""
              > end if
              >
              > end sub
              >
              >
              >
              >
              > [Non-text portions of this message have been removed]
              >
            Your message has been successfully submitted and would be delivered to recipients shortly.