-
May 15th, 2022, 08:21 PM
#1
How to get file permissions that are associated with a file?
This is what I have:
Code:
using System;
using System.IO;
using System.Text;
namespace File_Permissions
{
class Start {
static void Main(string[] args)
{
string dir = "dummy";
string dir_fil = "dummy/test.txt";
FileAttributes attributes = File.GetAttributes(dir);
System.Console.WriteLine(" These are the directory 'dummy' attributes : " + attributes.);
}
}
}
What I'm trying to do is get the attributes of a file/directory that you normally would see when you try to view the "Properties" on a file. I've found these examples, but it's kind of lacking:
https://www.tutorialspoint.com/file-...sions-in-chash
What's the best way to view _all_ of these properties? Specifically, I'd like to know how to view permissions, owner, etc. and then print all of this out to the console.
-
May 16th, 2022, 01:40 AM
#2
Re: How to get file permissions that are associated with a file?
Victor Nijegorodov
-
May 16th, 2022, 03:41 AM
#3
Re: How to get file permissions that are associated with a file?
Do you mean file permissions or file attributes? These are quite different.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
May 16th, 2022, 04:56 AM
#4
Re: How to get file permissions that are associated with a file?
Victor Nijegorodov
-
May 16th, 2022, 07:25 AM
#5
Re: How to get file permissions that are associated with a file?
Originally Posted by 2kaud
Do you mean file permissions or file attributes? These are quite different.
Is there a way to do both of them? Are there "file.printAllPermissions();" and "file.printAllAttributes();"? Or would I need to make that function myself?
-
May 16th, 2022, 08:26 AM
#6
Re: How to get file permissions that are associated with a file?
I guess you have to implement it yourself. Just see the examples and documentation and repeat output for each attribute you want to.
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|