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. Visual C++: File or Folder?

Visual C++: File or Folder?

Scheduled Pinned Locked Moved C / C++ / MFC
4 Posts 3 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.
  • K Offline
    K Offline
    Kuang Cao
    wrote on last edited by
    #1

    Hi, In Visual C++, if you create a file using CFile, is there any way to tell whether this file is a file or a folder? In Java, you can use "isDirectory()" to do this. Is there a similar way in Visual C++? Thanks. Or is there any other way to create a file? Any suggestion or comment is appreciated. Also, when using CFileDialog, all the folders and files will be displayed for you to select. Is there any way to only allow folders to show up? Thanks.

    A M 2 Replies Last reply
    0
    • K Kuang Cao

      Hi, In Visual C++, if you create a file using CFile, is there any way to tell whether this file is a file or a folder? In Java, you can use "isDirectory()" to do this. Is there a similar way in Visual C++? Thanks. Or is there any other way to create a file? Any suggestion or comment is appreciated. Also, when using CFileDialog, all the folders and files will be displayed for you to select. Is there any way to only allow folders to show up? Thanks.

      A Offline
      A Offline
      Ammar
      wrote on last edited by
      #2

      Try CFileFind::IsDirectory :cool: By the way, Doesn't CFile always create a file? I have never tried creating a folder. Can CFile do that? Ammar

      K 1 Reply Last reply
      0
      • K Kuang Cao

        Hi, In Visual C++, if you create a file using CFile, is there any way to tell whether this file is a file or a folder? In Java, you can use "isDirectory()" to do this. Is there a similar way in Visual C++? Thanks. Or is there any other way to create a file? Any suggestion or comment is appreciated. Also, when using CFileDialog, all the folders and files will be displayed for you to select. Is there any way to only allow folders to show up? Thanks.

        M Offline
        M Offline
        Michael Dunn
        wrote on last edited by
        #3

        Also, when using CFileDialog, all the folders and files will be displayed for you to select. Is there any way to only allow folders to show up? CFileDialog is not meant to do this. The folder-selection dialog is done with the SHBrowseForFolder() API. --Mike-- http://home.inreach.com/mdunn/ All your base are belong to ME~!

        1 Reply Last reply
        0
        • A Ammar

          Try CFileFind::IsDirectory :cool: By the way, Doesn't CFile always create a file? I have never tried creating a folder. Can CFile do that? Ammar

          K Offline
          K Offline
          Kuang Cao
          wrote on last edited by
          #4

          Sorry if I asked not good question. I am relatively new to Visual C++. I tried the CfileFind class. It seems that this the right one. But I still have some problems. The following is the code I tried. It works ok to find the specific file or directory. But when I tried to test whether this is a directory or not, it gives an "assertion failure". I have no idea how it happenes. Can you tell me what went wrong? Also, if possible, can you give me a little example (several lines) of how this may work? Thanks a lot. CFileFind finder; BOOL bWorking = finder.FindFile(filename); if(bWorking) { if(finder.IsDirectory()) { ...............

          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