Thread: Folders and text files

  1. #1
    Señor Member
    Join Date
    Jan 2002
    Posts
    560

    Folders and text files

    I have a program that uses a lot of loading/saving of text files, and I want some of these files to be unreadable to the user. I gave them weird extensions like .crse, but what I'd really like to do is make the files hidden or not readable in notepad. I guess I could encrypt them, but that would take a while, and my code is already messy. Also, with all of these files, my folder becomes really cluttered, is there a way for me to make new folders? Lastly, how do I delete folders and text files. Thanks in advance.

  2. #2
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    1. To make it unreadable, you can write it in binary.

    2. not sure

    3. I know there is a C function called remove in stdio.h, not sure about the C++ function.

  3. #3
    Señor Member
    Join Date
    Jan 2002
    Posts
    560
    What is binary and how would I implement it?

  4. #4
    Señor Member
    Join Date
    Jan 2002
    Posts
    560
    Oh never mind thats the 1001011 stuff, but is there a function to do it for me? Otherwise it will be just like encryption.

  5. #5
    Unregistered
    Guest
    binary... isn't that put in hex form like FF, EE, CD, 08,... ?


    I prefer encryption. Encryption in binary is even better. Otherwise, your output can still be read using hex viewers...

  6. #6
    Señor Member
    Join Date
    Jan 2002
    Posts
    560
    Fine, I guess encryption is the easiest way, but does anyone have an answer to my other questions?

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

    reply to files unreadable

    The easiest way is to do it in binary. Though I do lots of windows programming I've never actually learned file i/o using windows functions so this will have to do.
    #include <fstream.h>

    ifstream ifile; //input stream
    ofstream ofile; //output stream

    void main()
    {
    ifile.open("file.myfile", ios::in | ios::binary);

    }

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

    reply to files unreadable

    The easiest way is to do it in binary. Though I do lots of windows programming I've never actually learned file i/o using windows functions so this will have to do.
    #include <fstream.h>

    ifstream ifile; //input stream
    ofstream ofile; //output stream

    void main()
    {
    unsigned int whatever;

    // if you want more info look in the msdn or message me or
    // something
    ifile.open("file.myfile", ios::in | ios::binary);
    ifile.read((unsigned char *)&whatever, sizeof(unsigned int));
    ifile.close();
    }
    Last edited by sleex; 02-17-2002 at 12:12 PM.

  9. #9
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    You can use
    system("mkdir mydirname");
    to make a directory and
    system("rmdir mydirname");
    to remove a directory
    system ("attrib myfilename.txt +h");
    will hide the specified file.]

    You might have to include windows.h to use system.. but I'm not sure.

  10. #10
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    From stdlib

    system ("attrib file.dat +h")

    **Edit*** Doh! Beat me to it... damn telephone calls.
    Blue

  11. #11
    "The Oldest Member Here" Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,039
    is it possible that if you have the binary/hex code (3B 6Y GB) for a program, you can copy and paste the hex into your c++ code and output it into the machine code mess?

    for example,

    outputfile << "3E 4E 7K bal bal bal ablab....";
    and use ios::somthing that makes it into machine code instead of binary?

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

    hex in c++

    The compiler won't understand it unless there is some structure like _asm is for assembly language. And by the way the alpha characters in hex codes only go A-F.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Create Copies of Files
    By Kanshu in forum C++ Programming
    Replies: 13
    Last Post: 05-09-2009, 07:53 AM
  2. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM
  3. Necessary Files
    By Shastri in forum C++ Programming
    Replies: 3
    Last Post: 09-09-2004, 01:03 PM
  4. File reading in folders
    By CSoFun in forum C++ Programming
    Replies: 4
    Last Post: 03-11-2003, 07:35 PM
  5. Extansionless Files
    By Sentaku senshi in forum Tech Board
    Replies: 9
    Last Post: 09-27-2002, 04:56 PM