Question Change file permission to Read & Execute

jay_agno

Member
Joined
Apr 30, 2012
Messages
9
Programming Experience
Beginner
I'm working on a program on where I need to changed the file's permissions.
My problem is that I can't set the file to "Read and Execute".

I can set the file into "Read" with the code below, but how about "Read and Execute"?
VB.NET:
File.SetAttributes("C:\testfolder\sample.txt", FileAttributes.ReadOnly) ' Set file to Read and Execute.

Thank you for kind reply.
 

Attachments

  • Capture.PNG
    Capture.PNG
    61.3 KB · Views: 39
Why would you want to execute a .014 file? Give it the proper extension and just run it if it's a valid executable. Unless you want to hide the fact it's an executable, which is exactly why you can't set the executable flag on a non-executable file type.
 
File security is not set by file attributes, lookup GetAccessControl/SetAccessControl for that.
 
@Herman
I see. May be I'm asking the wrong question, or performing a nonsense code.

@JohnH
I'll look unto that.

Thanks for all of your help.
Mods may now close this thread.
 

Latest posts

Back
Top