Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6781311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:36:34+00:00 2026-05-26T16:36:34+00:00

If File.SetAttributes(C:\\myFile.txt, FileAttributes.ReadOnly); sets a file as read only, how do I set it

  • 0

If File.SetAttributes("C:\\myFile.txt", FileAttributes.ReadOnly); sets a file as read only, how do I set it back to read/write if I need to?

I suspect it would be FileAttributes.Normal however will this change any other properties of the file? There isn’t an awfully descriptive note on the MSDN site…

The file is normal and has no other attributes set. This attribute is
valid only if used alone.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:36:34+00:00Added an answer on May 26, 2026 at 4:36 pm

    To remove just the ReadOnly attribute, you’d do something like this:

    File.SetAttributes("C:\\myfile.txt", File.GetAttributes("C:\\myfile.txt") & ~FileAttributes.ReadOnly);
    

    This will remove the ReadOnly attribute, but preserve any other attributes that already exist on the file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to set attribute of a file in network to ReadOnly. File.SetAttributes(@\\data\ntshare\tmp\Trades_LastFileUploaded.csv, FileAttributes.ReadOnly);
FILE *out=fopen64(text.txt,w+); unsigned int write; char *outbuf=new char[write]; //fill outbuf printf(%i\n,ftello64(out)); fwrite(outbuf,sizeof(char),write,out); printf(%i\n,write); printf(%i\n,ftello64(out));
FileAttributes attrs = File.GetAttributes( path); File.SetAttributes( path, FileAttributes.Hidden ); attrs = File.GetAttributes( path); This
I came across this piece of code today: File.SetAttributes(excelFileName, File.GetAttributes(excelFileName) & ~ (FileAttributes.Archive |
I can't seem to change the read only flag on a file. I've tried
I need to delete a directory that contains read-only files. Which approach is better:
File formats I would like to play include .wav, .mp3, .midi. I have tried
File: /home/USER/DIR/a http://www.here.is.a.hyper.link.net/ /home/USER/DIR/b http://www.here.is.another.hyper.link.net/ Need to remove all the odd lines in this
File 1: asdffdsa File 2: asdfjklfdsaHGUik How do I read these binary files with
file.txt contains: ##w## ##wew## using mac 10.6, bash shell, the command: cat file.txt |

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.