Read Only files

This is a discussion on Read Only files within the C++ Programming forums, part of the General Programming Boards category; A new headache: Is there any way to set the read-only property of a file from within one's program? Or ...

  1. #1
    Anal comment spacer DominicTrix's Avatar
    Join Date
    Apr 2002
    Posts
    120

    Read Only files

    A new headache:

    Is there any way to set the read-only property of a file from within one's program? Or indeed to write to a read only file?

    Help would be hugely appreciated


    dt
    "The most important thing about acting is honesty. If you can fake that you've got it made" - George Burns

  2. #2
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    It is OS specific, as it will be based on the file system and the OS API. You could tell us what OS, etc... you're using, or check yourself at some reference for that OS (MSDN, etc...)

  3. #3
    Anal comment spacer DominicTrix's Avatar
    Join Date
    Apr 2002
    Posts
    120
    Oh really, well I stumbled across a pretty dirty method using the DOS command ATTRIB and using ::system("attrib -r \"filename.txt\"") etc. I'm using Windows XP and I'm hoping that'll work across all windows platforms.
    I can't believe there isnt a method in MFC or something tho..

    thx
    "The most important thing about acting is honesty. If you can fake that you've got it made" - George Burns

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,676
    SetFileAttributes()

    Don't forget about the requirements:
    >> Requires Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, or Windows 95.

    gg

  5. #5
    Anal comment spacer DominicTrix's Avatar
    Join Date
    Apr 2002
    Posts
    120
    brilliant, ty
    "The most important thing about acting is honesty. If you can fake that you've got it made" - George Burns

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Read INDEX.DAT files?
    By Queatrix in forum Windows Programming
    Replies: 3
    Last Post: 09-08-2006, 08:03 AM
  2. using threads to write & read from files
    By kishorepalle in forum C Programming
    Replies: 4
    Last Post: 10-19-2004, 05:19 PM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. trying to read all asci char's in files
    By brane_sail in forum C++ Programming
    Replies: 1
    Last Post: 09-02-2002, 11:33 AM
  5. Replies: 1
    Last Post: 07-24-2002, 06:33 AM

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