xml file should not open

This is a discussion on xml file should not open within the C++ Programming forums, part of the General Programming Boards category; if some body clicks on the Xml file, it should not open in the explorer in the sense user is ...

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    7

    xml file should not open

    if some body clicks on the Xml file, it should not open in the explorer in the sense user is not allowed to modify the file.

    can any one suggest me how to do this programatically?

  2. #2
    Banned
    Join Date
    Jun 2005
    Posts
    594
    you could always encode it but and then decode it in a temp file
    or into memory only, if that a possiblity.

  3. #3
    Registered User mitakeet's Avatar
    Join Date
    Jun 2005
    Location
    Maryland, USA
    Posts
    212
    Make the file read-only.

    Free code: http://sol-biotech.com/code/.

    It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
    --Me, I just made it up

    The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
    --George Bernard Shaw

  4. #4
    #include<xErath.h> xErath's Avatar
    Join Date
    Jun 2004
    Posts
    722
    to block a file from write/read acess while open specify FILE_SHARE_DELETE,FILE_SHARE_READ or FILE_SHARE_WRITE with CreateFile function.
    http://msdn.microsoft.com/library/de...createfile.asp

    for posix open().... I don't know
    http://www.opengroup.org/onlinepubs/.../xsh/open.html

  5. #5
    Registered User
    Join Date
    Oct 2004
    Posts
    7
    i am awre of this but the problem is every time i have to do encode and decode. Even this is not good one. Becoz he can open the Encoded file and deletes some thing, then the worest case is i can not decode it.

  6. #6
    Registered User
    Join Date
    Oct 2004
    Posts
    7
    user can select the file, right click on the properties dialog box , Uncheck the readonly option. After that he will be able to do editing.

  7. #7
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    Quote Originally Posted by anil_beloved
    user can select the file, right click on the properties dialog box , Uncheck the readonly option. After that he will be able to do editing.
    It's really not very nice to try to stop the user from editing plain text files on his own system. That's why that box can be unchecked. Perhaps you should consider saving the data in a binary format, or as a very minimalist solution, change the file extension of the XML file to something that Windows won't have registered with a program.
    Away.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  2. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM

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