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

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.

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

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

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.