944,201 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 18254
  • C++ RSS
Mar 23rd, 2005
0

How to change DIRECTORY ATTRIBUTES through C or C++

Expand Post »
Hi Friends,

Can anyone tell how to change the attributes of a directory through C or C++.

I have tried to found in my compiler's help file but it was showing the method to change the file attributes but not the directory's.

I want to change the attributes of a directory from Read/Write to Read only and vice versa in my program.

Please help.......

Thanks in Advance.

Regards
Rituraj Raina
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
riturajraina is offline Offline
12 posts
since Sep 2004
Mar 23rd, 2005
0

Re: How to change DIRECTORY ATTRIBUTES through C or C++

You cannot make a directory readonly (at least, not in DOS). you can only make it's files and the files in it's subdirectories readonly. Even if you could make a directory readonly, it would be useless because directories are treated differently to files, even though they are just files with the directory attribute.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sinB is offline Offline
11 posts
since Dec 2004
Mar 23rd, 2005
0

Re: How to change DIRECTORY ATTRIBUTES through C or C++

Quote originally posted by riturajraina ...
Hi Friends,

Can anyone tell how to change the attributes of a directory through C or C++.

I have tried to found in my compiler's help file but it was showing the method to change the file attributes but not the directory's.

I want to change the attributes of a directory from Read/Write to Read only and vice versa in my program.

Please help.......

Thanks in Advance.

Regards
Rituraj Raina
I think there are couple of ways to do this. Simplest I think is use the system call and use OS specific command within. e.g system("attrib +r mydir") will make mydir read-only.

cheers,
aj.wh.ca
Reputation Points: 12
Solved Threads: 1
Junior Poster in Training
aj.wh.ca is offline Offline
53 posts
since Mar 2005
Mar 24th, 2005
0

Re: How to change DIRECTORY ATTRIBUTES through C or C++

Thanks a lot friends for your prompt help.

I think i have done a great exploration by finding this group.

I am sorry that i didn't explained my problem in detail in my last post.

Well better late than never.

Here it is.

Actually i am developing a project in which i have to keep the user's data in a folder which has been kept in a server(Win2k based) on my network.

The folder will be shared with all the users and all rights(read/write/modify etc.)will be granted to all the users on the folder(its a requirement of the my program).

Now my main worry is that since all the users will be granted full rights on the shared folders, hence if someone gets a mischief and he/she deletes all the contents of the shared folder , then all the userfull data of the users will be lost.

Hence i want to develop a mechanism in which only some users will be having all the rights while some users will be having readonly rights and I want this assignment of rights on the shared folder(installed on server) to be done through my C++ program (installed on client machines).

Can anyone suggest a remedy for this???

Thanks Again
Rituraj Raina
Reputation Points: 10
Solved Threads: 0
Newbie Poster
riturajraina is offline Offline
12 posts
since Sep 2004
Mar 25th, 2005
0

Re: How to change DIRECTORY ATTRIBUTES through C or C++

Hi Rituraj ,
Unless you have some other requirement for the program you are trying to develop I would call it re-inventing the wheel. For the purpose you have written, I would strongly suggest that you use Win2K control panel. You can easily assign rights on a folder (which has users data) on a per user basis. Its a very simple task that way.
regards,
aj.wh.ca
Reputation Points: 12
Solved Threads: 1
Junior Poster in Training
aj.wh.ca is offline Offline
53 posts
since Mar 2005
May 22nd, 2005
0

Re: How to change DIRECTORY ATTRIBUTES through C or C++

hi, i am also interested in modifying a files attributes using C++. Symbian OS as far as I know how has no OS built in commands for modifying a files attributes... It works on the same basis of windows attributes, because files modified on an mmc by windows retain the same attributes in Symbian OS. I was wondering if anyone has a method coded into C++ for modiyfing file attributes, particularly hidden/not hidden...

Many thanks.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
boggsi is offline Offline
1 posts
since May 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: help
Next Thread in C++ Forum Timeline: Skeleton for a game.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC