문제

FileAttributes attrs = File.GetAttributes( path);
File.SetAttributes( path, FileAttributes.Hidden );
attrs = File.GetAttributes( path);

This code snippet works on my NTFS file system (C:\Temp...\whatever_file). But when I try to perform this same operation on a USB key (FAT file system) it never successfully sets the Hidden attribute. If I manually set it in Windows Explorer, then the first line returns correctly that it is set. But the third line (checking it) never sets it if its not set.

I'll give a free puppy to whoever can tell me why. :)

UPDATE: When I say it doesn't work, I mean when I go back to Windows Explorer and look at the file it doesn't have the hidden attribute set. In fact, when I do the second GetAttributes it shows that the bit is set. But in Windows Explorer it is not set. Even if I remove the USB key and reinsert it to be sure it refreshes correctly.

도움이 되었습니까?

해결책

Thank you all for your input, but I completely neglected to look at the REST of my code where I recursively turn off the read-only attribute on all of the files I've written to my USB key, thus negating whatever I'd done before.

I repent in dust and ashes.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top