This line is copied from Bob Keeney’s review of Xojo 2019 3.1:
In my apps, I encounter files that have their f.visible property set to false. I copy the file(s) to a new location, but the f.visible property remains set to false. How can I set the property to true now in Xojo?
Many thanks for any advice.
I just tested it in Xojo 2019R3.1 and it still works for me, whether setting the visibility to true or false. Can we see your code?
Maybe a platform difference ?
@Gavin Smith Sure. Here you go.
f.CopyFileTo(theDestination)
If f.LastErrorCode = 0 and f.visible = false Then 'set the f.visible property to true
f.visible = true
end if
you sure you dont want to check theDestination instead of f ?
@Norman Palardy Yes, theDestination has been checked earlier in the code. The file copies okay, but it’s visible property is set to false and I am unable to change it.
What does “visible” mean in this context?
@Tim Streater
It’s is not seen in the finder unless you set the finder to include hidden files. When you do, you see it as in the pic below.
So just to clarify, you want to set the visibility of the original file to true? Because it sounded like you wanted to set the visibility of the copied file.
If you set a breakpoint, does it actually hit the f.visible = true
line?
What is the name of the file ?
.My_Nice_File.bin
(for example ?)
Edit:
What DropBox comes in for ?
Sorry @Norman Palardy , I misunderstood your reply. I’ve rewritten the code as follows but I’m still stumped:
dim theCopy as folderitem
f.CopyFileTo(destinationFolder)
theCopy = getfolderitem(destinationFolder(f.name, true).URLPath)
if theCopy <> nil and theCopy.visible = false Then
theCopy.visible = true
end if
f is the file I want to copy. It is nested in a folder whose name begins with a period (.) and, as a result, is hidden in the Finder, for example .SourceFolder. I successfully copy f from .SourceFolder to destinationFolder and then create a folder item of it which is named theCopy. But I cannot change theCopy.visible to True.
Some days ago someone already talked about something you just wrote
Read his post for more details.
Edit:
Doh ! It was already an Anthony question
https://forum.xojo.com/58401-copying-a-file-nested-in-a-hidden-folder
What DropBox comes in for ?
DROPBOX appears in the screen shot.
@Emile Schwarz
A Dropbox link is in the user definable bar of the Finder window so disregard.
@Gavin Smith
Hello Gavin. I want to change the visible property on the copy of the original file. I updated my code if you dont mind having another look.
oh thats … interesting code
dim theCopy as folderitem
f.CopyFileTo(destinationFolder)
theCopy = destinationFolder.child(f.name)
if theCopy <> nil and theCopy.visible = false Then
theCopy.visible = true
end if
is there anything special about the destination ? is it a drop box folder or something like that ?
@Norman Palardy
Hahaha, now you can see the level of my coding ability. destinationFolder is your run-of-the-mill folder that Im able to write other files to. Its on a local hard drive.
what about:
if theCopy <> nil then//and theCopy.visible = false Then
theCopy.visible = true
end if
May be the finder is sluggish. What about waiting a couple of secs before setting visible to true?
And pretty please don’t do
if folderitem.visible = false then
That’s rather convoluted. Do
if not folderitem.visible then
instead.
Im not even sure why its being checked first
Set it anyway?
Whats wrong with this: ?
dim theCopy as folderitem = destinationFolder.child(f.name)
if thecopy <> nil then
f.CopyFileTo(thecopy)
theCopy.visible = true
end if