Me too I am struggling with the ‘FolderItem.Constructor’ replacing the Deprecated ‘GetFolderItem’.
In my old code :
OpenDocument is a String containing the Path for a loaded file (D:\MyMusic\Etienne\Perferct.mid)
f is declared as a folderitem
old code is : f = GetFolderItem(OpenDocument)
This works very well, but in 2019r2 API2 ‘GetFolderItem’ is deprecated.
What code should I use in API2 for replacing my : f = GetFolderItem(OpenDocument)
Thanks
the constructor just have more arguments in case of path is used
'Dim f As New FolderItem("C:\\Temp\\Test.txt")
Dim f As New FolderItem("C:\\Temp\\Test.txt",FolderItem.PathModes.Native)
System.DebugLog(Str(f.Exists))
you said “the New API Folderitem should look like”
var f as new FolderItem(Prefs.DefaultFolder,FolderItem.PathTypeNative)
or
var f as FolderItem = new FolderItem(Prefs.DefaultFolder,FolderItem.PathTypeNative)
But this give the following warning:
Warning: Constructor is deprecated. You should use Contructor(path As String, pathMode As PathModes, followAlias As Boolean) instead.
This gives the same warning
“Warning: Constructor is deprecated. You should use Contructor(path As String, pathMode As PathModes, followAlias As Boolean) instead.”
[quote]GetFolderItem is deprecated. You should use FolderItem.Constructor(path As String, pathMode As PathModes) instead.
[/quote]
simply means
change getFolderItem(…) to new FolderItem(…)
The constructor method is what you get when you NEW something, if it can take parameters.
eg
x = new myClass
x = new myClass( 29)
x = new myClass (somevariable, someinteger)
All of thes call a constructor.. a class can have several constructors… the actual one called is determined by the parameters you pass.
But you do not have to use the word Constructor
The constructor method is what you get when you NEW something, if it can take parameters.
eg
x = new myClass
x = new myClass( 29)
x = new myClass (somevariable, someinteger)
All of thes call a constructor.. a class can have several constructors… the actual one called is determined by the parameters you pass.
But you do not have to use the word Constructor[/quote]
I’m not able to found the correct spelling
give the warning
Gives an error
doing as you suggested change getFolderItem(…) to [b]new FolderItem(…)[/b
Shows a a warning:
Warning: Constructor is deprecated. You should use Contructor(path As String, pathMode As PathModes, followAlias As Boolean) instead.
[quote=458178:@Volbragt Etienne]One little question :
What does the last optional parameter ‘False’ or ‘True’ means.
Regards
Etienne[/quote]
If the file is a symbolic link/shortcut/alias, you’ll get the actual file if you pass true. If you pass false, you’ll instead get the file that the symbolic link/short/alias points too.