Creating files then Hiding them or making them Read-Only...how?

This is a discussion on Creating files then Hiding them or making them Read-Only...how? within the C++ Programming forums, part of the General Programming Boards category; I know how to do File I/O, but now I want to be able to hide the files I create, ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    145

    Unhappy Creating files then Hiding them or making them Read-Only...how?

    I know how to do File I/O, but now I want to be able to hide the files I create, just as if they had been Hidden from the Properties menu of the file. Is there any way I can do this? Thanks in advance!


    Kyoto Oshiro
    http://www.angelfire.com/realm2/horizon/files.html
    Horizon Games

  2. #2
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    I remember seeing it on the board before but I can't seem to find it. Look around and you will probably get it. I think that the person used the system comand such as:

    system("C:\\file.txt -h")//it is the -h or whatever it is that makes it hidden

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    203

    void open(const char *filename, int mode, int access);

    i may be wrong...
    the open() function can take 3 arguments, with the 3rd argument being file access of type int
    0 = normal //default
    1 = read-only
    2 = hidden
    4 = system
    8 = archive
    so it looks something like this:
    ofstream out;
    out.open(filename, ios:ut, x); //where x is file access

    it can be ORed with |
    out.open("test.dat", ios:ut, 1 | 2); //read-only and hidden

    i believe you must send something (cant leave blank) as the 2nd argument in order to use the 3rd (file access)

    only 1 out of the 4 books i'm using to learn c++ has mentioned this at all. play around with it and lemme know what kind of problems you encounter

  4. #4
    Registered User
    Join Date
    Mar 2002
    Posts
    203
    eh those smillies are : o without the space if you didnt know

  5. #5
    Registered User
    Join Date
    Feb 2002
    Posts
    145

    Lightbulb Thanks you guys

    Alright everyone, thanks for your help with this!


    Kyoto Oshiro
    Horizon Games

  6. #6
    Registered User
    Join Date
    Feb 2002
    Posts
    145
    Okay, I tried to make the folder hidden by using this...

    out.open("Text.txt", ios:ut, 1);

    However, no matter what number I put in in place of the 1, the file will not hide, it will only become read-only or archive. Is there some secret number I missed along the line? At least I can get it read-only...which is a start. Any ideas would be appreciated!


    Kyoto Oshiro
    http://www.angelfire.com/realm2/horizon/files.html

  7. #7
    Registered User
    Join Date
    Mar 2002
    Posts
    203
    i've looked around some and can't find anything else about file access. None of the tutorials i've seen even mention anything about it. I'll keep searching

  8. #8
    Registered User
    Join Date
    Feb 2002
    Posts
    145
    I have tried to search for anything myself, but all that I come up with involves UNIX or something totally off the topic of C++. It is strange that this sort of information wouldn't be included in some File I/O tutorial. Must be a hidden topic (what a bad pun).


    Kyoto Oshiro
    http://www.angelfire.com/realm2/horizon/files.html
    Horizon Games

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating header files
    By histevenk in forum C++ Programming
    Replies: 14
    Last Post: 10-17-2007, 09:02 PM
  2. loop doesn't read files
    By Yumin in forum C++ Programming
    Replies: 5
    Last Post: 05-21-2006, 07:43 PM
  3. How to read files?
    By Raigne in forum C++ Programming
    Replies: 17
    Last Post: 11-23-2005, 05:03 PM
  4. Creating a prog to edit files with certin extention
    By destroyer32428 in forum C++ Programming
    Replies: 2
    Last Post: 11-25-2001, 03:08 AM
  5. Making MIDI files.... HOW??!!
    By sean in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 11-08-2001, 05:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21