How to tell if a path is a directory or a file

Updated on technology 2024-05-12
3 answers
  1. Anonymous users2024-02-10

    The thirteenth findfirstfile looks for the file and gets the information of the file.

    Let's take an example to list all the files in the first directory of the E drive, including folders, and combine them with FindNextFile

    #include

    #include

    intmain()

    booldone=true;

    win32_find_data

    fd;handle

    hfindfindfirstfile("e:\\",fd);The first parameter is the pathname, which can use wildcards, and people who know DOS should know it! FD stores information about the file.

    whiledone)

    printf("%s",;

    done=findnextfile(hfind,fd);If the returned value is 0, there are no files to find.

    return

    Of course, you can also just find a file and don't use wildcards, but what's the point? , such as this can actually get information about a file, such as whether the file is hidden, or whether it has read-only attributes, etc.

    Of course, by controlling wildcards, you can also look for specific types of files, for example, I only need to find text files, then this statement findfirstfile("e:\\txt",&fd);That's it, it's up to you to use it flexibly.

    As mentioned earlier, there is information about the file stored in the fd, so how to judge the properties of the file according to the members in the fd, whether the file is hidden, whether it is a folder.

    The dwfileattributes in the fd store the information of the file, such as judging whether it is a folder, as long as this variable and the file attribute directory are bitwise and arithmetic, if it is 1, it indicates that it is a document folder, such as.

    printf("%s is the folder",;

    The same is true for other judgments, now give the file attribute (commonly used): file attribute hidden

    File Attribute ReadOnly File Attribute System

    The fourteenth findnextfile looks for the file.

    Follow the FindFirstFile function for example!

  2. Anonymous users2024-02-09

    If you are using the UNIX Linux operating system, you can use a powerful shell programming method to determine whether the current path is a word directory or a file; As for how to use powerful shell programming techniques to achieve your own goals, you must read the detailed documentation related to shell programming, as well as sed, awk, etc.

  3. Anonymous users2024-02-08

    In a computer, a text identifier that points to a file or something that is pathed, usually with a slash.

    or"/"Each interval is separated, with the slash followed by the previous child.

    Represents the root path of the current path.

    Eliminate envy represents the current path.

Related questions
13 answers2024-05-12

A woman sometimes suddenly chats and chats without information, and never sends me a message, not once. But I don't exclude me from spending money on her, buying her things, and sending Douyin or something that clearly shows that she has sent it, but when I go to see it, I can't see anything, I don't know if she likes me too, please solve everyone.

27 answers2024-05-12

How narcissistic do you have to think like this, girls don't like you, will they take the initiative to sleep with you? Do you like a person, in fact, it is easy to feel it by talking and looking at it, and you can slowly experience it yourself.

25 answers2024-05-12

Whether it is an acid or a base depends on the specific definition of the acid and base, and it also depends on the specific reaction. >>>More

6 answers2024-05-12

To judge the rawness or ripeness of watermelon, you can by: >>>More

20 answers2024-05-12

Hello, it's easy to tell the difference between a real smile and a fake smile. Generally, people who really smile will show a very cheerful appearance, and people who fake smiles generally laugh very stiffly, which belongs to the kind of bitter smile. In fact, the real smile and fake smile can be seen at a glance. >>>More