Reputation: 41
In C#, for changing attribute of folder, I use FileAttributes. Example:
myfolder= "C:\\Test Programs\\Avatar";
DirectoryInfo ss = new DirectoryInfo(myfolder);
ss.Attributes = FileAttributes.Normal;
--> Done! Attribute of Avatar is Normal.
But, with some folder which name are " ":
myfolder= "C:\\Test Programs\\ ";
My program doesn't throw any errors but attribute of that folder isn't change. What can i do?
(some viruses created a hidden folder with name is " " and moved all data on usb flash disk into it. I want to remove hidden attribute of that folder)
My English grammar isn't good. Sorry about that!
Upvotes: 1
Views: 1074
Reputation: 41
Done!. I added "\\"
into myfolder.
With folder Avatar --> myfolder= "C:\\Test Programs\\Avatar\\";
With folder which name is " " --> myfolder= "C:\\Test Programs\\ \\";
And my program set Attribute of that folder to Normal.
Thanks every one!.
Upvotes: 2
Reputation: 205
Try adding + System.Net.WebUtility.HtmlDecode(@" ") +"\\"
to the end of your directory name instead of the space.
Your string will look like this:
myfolder= "C:\\Test Programs\\ " + System.Net.WebUtility.HtmlDecode(@" ") + "\\";
Upvotes: -1