Is there a way to set the attribute of a file to ‘hidden’ in code in Windows?
The file attributes are read-only.
I imagine I could shell to attrib.exe with +H parameter but want to avoid the DOS window that would appear briefly.
Cant find anything MBS-wise either at the moment…
Dim x As Folderitem
x.Visible = False
The shell window does not appear when using Shell…
However, Christophe posted the best solution for that particular case.
x.Visible = False
The docs do say that, but…
Actually, I marked it as the best solution too soon.
It doesn’t seem to be working (at least on OSX, and yes I know I started talking about Windows, but a simple . sorts it out on a Mac and Im trying to keep as much shared code as I can)
It works just fine here. But in Mac OS X or Linux, you must have write permissions.
This lifts the read only permission before changing visible, then puts it back :
dim f as folderitem = SpecialFolder.desktop.child("Keep it working - Thunderbird - MozillaZine Knowledge Base.webloc")
dim previousPermissions as integer = f.Permissions
f.visible = not f.visible
f.permissions = previousPermissions
You need to use #If not TargetWin32
since Windows does not support permissions.
Not read only, so I don’t need the permissions aspect here… I am creating the file.
Currently I can only get it to work if I save the file, then set the folder item to nil, then get a new reference and set visible = false
[code] f2 = GetFolderItem(thepath)
f2.SaveAsJPEG thepicture
f2 = nil
f2 = GetFolderItem(thepath)
f2.Visible = false[/code]
You do not give enough time for the system to finish closing the file. Set visible in a timer a couple ticks away.