Write attributes

  • Thread starter Thread starter juli jul
  • Start date Start date
J

juli jul

Hello how can I change/write some attributes in xml document?(for some
elements)
Thank you!
 
Hei,
The problem is that I am doing:
File.Copy(this.file_name,this.save_name,true);

Than I want to edit some of the attributes in the new copy ,how can I do
it?
Not to add new attributes but to edit(rewrite) some of the attributes in
the document) How? Thanks a lot!
 
Hi,

I haven't tested it but you can try it:

FileAttributes yourAttributes;
string yourFilePath;

FileInfo fileInfo=new FileInfo(yourFilePath);
fileInfo.Attributes=(yourAttributes);
fileInfo.Refresh();

//test
if( fileInfo.Attributes==yourAttributes ) {
// all OK ;-)
}
else {
// find another way :-(
}

HTH
Marcin
 
juli jul said:
The problem is that I am doing:
File.Copy(this.file_name,this.save_name,true);

Than I want to edit some of the attributes in the new copy ,how can I do
it?
Not to add new attributes but to edit(rewrite) some of the attributes in
the document) How? Thanks a lot!

Don't make a copy first. Load the file with XmlDocument.Load, then
change the attributes, then use XmlDocument.Save to save the new copy.
 
Back
Top