I am storing NativePaths in a database. When my app loads I iterate through the native paths and create folder items from the paths. If i delete the item referenced by one of the paths my app throws an exception at dim f as new FolderItem(res(n,0),FolderItem.PathTypeNative). I thought this would work and then pick up at the next line if f.exists that it no longer exists.
The exception is UnsuportedFormatException - The path passed into new FolderItem was invalid
for N as integer = 0 to UBound(res,1)
dim f as new FolderItem(res(n,0),FolderItem.PathTypeNative)
if f.Exists = True then
pIcon = brick
else
pIcon = brick_error
end if
frmmain.SourceList.AddMenuItem(res(n,0),res(n,0),"$keyActiveProjects" ,pIcon)
f = nil
next N
end if
[quote=111523:@Mike Charlesworth]I am storing NativePaths in a database. When my app loads I iterate through the native paths and create folder items from the paths. If i delete the item referenced by one of the paths my app throws an exception at dim f as new FolderItem(res(n,0),FolderItem.PathTypeNative). I thought this would work and then pick up at the next line if f.exists that it no longer exists.
The exception is UnsuportedFormatException - The path passed into new FolderItem was invalid
[/quote]
I assume you mean that the path your trying to resolve you delete from the local machine
Say you had saved a path of
/a/b/c
and remove b, c or a that you get the problem ?
why not use a try catch ?
for N as integer = 0 to UBound(res,1)
try
dim f as new FolderItem(res(n,0),FolderItem.PathTypeNative)
if f.Exists = True then
pIcon = brick
else
pIcon = brick_error
end if
frmmain.SourceList.AddMenuItem(res(n,0),res(n,0),"$keyActiveProjects" ,pIcon)
f = nil
catch UFE as UnsuportedFormatException
end try
next N
end if
I was going to suggest using GetSaveInfo for storing the file path. I was surprised that Norman did not mention it. Is GetSaveInfo no longer preferred over .NativePath for storing file paths in files and DBs?