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. Validate a filename

Validate a filename

Scheduled Pinned Locked Moved C / C++ / MFC
c++questioncomhelptutorial
5 Posts 4 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.
  • J Offline
    J Offline
    JC Gauthier
    wrote on last edited by
    #1

    How do you know if a combination of a path and filename is valid ? I don't want to know if it is an actual existing file but only if it's valid (does not contain any invalid caracters). Also, I do not want to create a file on the disk to know if I'll receive an invalid filename error. So, how can I know if a path + filename combination has a valid syntax ? (example: "C:\folder name\file name.ext" is valid, "C:\folder name\file&?n!.ext" is invalid) I'm using C++ only (no MFC, etc). Thanks a lot ! =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= J.-C. Gauthier - http://www.grandmenhir.com/

    V G 2 Replies Last reply
    0
    • J JC Gauthier

      How do you know if a combination of a path and filename is valid ? I don't want to know if it is an actual existing file but only if it's valid (does not contain any invalid caracters). Also, I do not want to create a file on the disk to know if I'll receive an invalid filename error. So, how can I know if a path + filename combination has a valid syntax ? (example: "C:\folder name\file name.ext" is valid, "C:\folder name\file&?n!.ext" is invalid) I'm using C++ only (no MFC, etc). Thanks a lot ! =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= J.-C. Gauthier - http://www.grandmenhir.com/

      V Offline
      V Offline
      valikac
      wrote on last edited by
      #2

      One solution is to create a temporary file or path. Kuphryn

      A 1 Reply Last reply
      0
      • J JC Gauthier

        How do you know if a combination of a path and filename is valid ? I don't want to know if it is an actual existing file but only if it's valid (does not contain any invalid caracters). Also, I do not want to create a file on the disk to know if I'll receive an invalid filename error. So, how can I know if a path + filename combination has a valid syntax ? (example: "C:\folder name\file name.ext" is valid, "C:\folder name\file&?n!.ext" is invalid) I'm using C++ only (no MFC, etc). Thanks a lot ! =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= J.-C. Gauthier - http://www.grandmenhir.com/

        G Offline
        G Offline
        gmontem
        wrote on last edited by
        #3

        This article titled "Making Room for Long Filenames" in the location "Windows Base Services General Technical Articles " of the MSDN Library has a few general guidelines for long filenames, and they include: - The application must not use the following characters in directory names or filenames, because they are reserved for Windows: < > : " / \ | - The application must not use reserved words, such as aux, con, and prn, as filenames or directory names. The documentation forgot to mention that asterisk (*) and the question mark (?) are also invalid characters.

        1 Reply Last reply
        0
        • V valikac

          One solution is to create a temporary file or path. Kuphryn

          A Offline
          A Offline
          Anonymous
          wrote on last edited by
          #4

          Unfortunately, I do not want to do that (like mentionnend in the original post) Its a possible solution but I would like to use only if everything else should fail :)

          V 1 Reply Last reply
          0
          • A Anonymous

            Unfortunately, I do not want to do that (like mentionnend in the original post) Its a possible solution but I would like to use only if everything else should fail :)

            V Offline
            V Offline
            valikac
            wrote on last edited by
            #5

            Testing is the only programming solution. Kuphryn

            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