Skip to content

Changing directory and file permission on linux with C# 5.0 #45641

Answered by PathogenDavid
tbonham asked this question in Q&A
Discussion options

You must be logged in to vote

I want to see if there a linux way so I can update my class to work on both OS's.

The filesystem permissions model in Linux is far too different from Windows to make a general-purpose solution unless your needs are extremely limited. (Like all you want is to toggle a file as read-only.)

As far as I'm aware, Mono.Posix.NETStandard is still the way to go if you need access to stuff like that on Linux. You can use one of the child classes of Mono.Unix.UnixFileSystemInfo to manipulate the permissions of a file, or you can just call chmod directly.

(See also: #19958)

(Also I'm unsure if those documentation links are still being updated. They may not be entirely up-to-date.)

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by danmoseley
Comment options

You must be logged in to vote
1 reply
@HendrikKoelbel
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants