473,404 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

FileAttributes

Help My Brain is apparently not working!

I have been trying to toggle FileAttributes in C# code to no avail. Nothing
I have tried has worked and I have been unable to find anything anywhere on
toggling the bits properly.

Depending on the file I need to either turn off the "Archive" bit or the
"ReadOnly" bit; whether it is on or not I need to turn it off.

Everything I have tried generates an error.

Please Help.

Thanks in Advance

Frank


Nov 16 '05 #1
1 3956
Frank wrote:
I have been trying to toggle FileAttributes in C# code to no avail. Nothing
I have tried has worked and I have been unable to find anything anywhere on
toggling the bits properly.

Depending on the file I need to either turn off the "Archive" bit or the "ReadOnly" bit; whether it is on or not I need to turn it off.


Something like this will turn off both Archive and ReadOnly attribute
bits. Modify to suit your needs:

FileAttributes attr = FileAttributes.Archive |
FileAttributes.ReadOnly;

File.SetAttributes( fname, File.GetAttributes( fname) & (~attr));
--
mikeb
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Yves Dhondt | last post by:
Hello, one of the possible attributes of a file or a directory is ReparsePoint. When there is such a point, there is a block of user-defined data associated with the file/directory. In the past...
3
by: StGo | last post by:
How can i read/write file's custom attributs(like subject,author...) in C#??? Thanks :))
2
by: Daniel Garavaldi | last post by:
Hi C# Gurus Has anybody of you experience with FileAttributes? I'm looking for alternatives and elegant solutions when opening a file with FileInfo and query the file-attributes (read-only,...
5
by: Fresh Air Rider | last post by:
Hello Could anyone please explain how I can pass more than one arguement/parameter value to a function using <asp:linkbutton> or is this a major shortfall of the language ? Consider the...
1
by: Edgardo Rossetto | last post by:
Quoting from MSDN docu: "This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values" I don't get it, how can I check if FileSystemInfo.Attribute has...
1
by: Phil Haddock | last post by:
Can anyone post a code snippet on how to retrieve Permission information on a Folder? (Visual Basic 2005) There's lot's of information on how to set a permission, but I can't figure out how to...
3
by: Alan T | last post by:
This is the code: FileAttributes attributes = File.GetAttributes(sFileName); MessageBox.Show(attributes.ToString()); The message box shows "ReadOnly, Archive"
1
by: mgonzales3 | last post by:
I'm trying to compare DirectoryInfo.Attributes to FileAttributes like so: // result returning // Directory | Archive DirectoryInfo info = new DirectoryInfo(this.folderFullName); if...
18
by: jonpfl | last post by:
All, Can I use WScript inside an ASP page to kick off another process and post back to the client while this other process is still running? The reason I want to do this is because we are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.