ffdshow Posted April 14, 2009 Share Posted April 14, 2009 (edited) Why the next code doesn't work: $attrib = FileGetAttrib(@HomeDrive & "\file") $len = StringLen($attrib) $split = StringSplit($attrib, "") For $i = 1 To $len FileSetAttrib(@HomeDrive & "\file", '"-' & $split[$i] & '"') Next Attributes is not removed. Edited April 14, 2009 by ffdshow Link to comment Share on other sites More sharing options...
DaRam Posted April 14, 2009 Share Posted April 14, 2009 (edited) You want to remove all attributes set right?You do not need to iterate through each attribute Just use this:$attrib = FileGetAttrib(@HomeDrive & "\file") FileSetAttrib(@HomeDrive & "\file", "-" & $attrib)If you do not care about what attributes are already set and just want to remove all thenFileSetAttrib(@HomeDrive & "\file", "-RASHNOT")Edit: You cannot set the D (DIRECTORY) AND C (COMPRESSED) Atttributes, so the first method could fail if applied to a file with these attributes set. Edited April 14, 2009 by DaRam Link to comment Share on other sites More sharing options...
ffdshow Posted April 14, 2009 Author Share Posted April 14, 2009 If you do not care about what attributes are already set and just want to remove all thenI want to add some lines to the end of that file and then to restore all attributes. Link to comment Share on other sites More sharing options...
zorphnog Posted April 14, 2009 Share Posted April 14, 2009 $sOrigAttrib = FileGetAttrib(@HomeDrive & "\file") FileSetAttrib(@HomeDrive & "\file", "-RASHNOT") ; do something to file FileSetAttrib(@HomeDrive & "\file", "+" & $sOrigAttrib) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now