# Folderitem

**URL:** <https://forum.xojo.com/t/folderitem/17957>\
**Category:** General\
**Created:** [July 14, 2014, 10:31pm UTC](https://forum.xojo.com/t/folderitem/17957 "2014-07-14T22:31:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_Charlesworth](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/958977/32.png) [@Mike\_Charlesworth](https://forum.xojo.com/u/Mike_Charlesworth)\
**Post date:** [July 14, 2014, 10:31pm UTC](https://forum.xojo.com/t/folderitem/17957/1 "2014-07-14T22:31:31Z")

</div>

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

```auto

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
```

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [July 14, 2014, 10:41pm UTC](https://forum.xojo.com/t/folderitem/17957/2 "2014-07-14T22:41:00Z")

</div>

[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 ?

```auto

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
```

---

<div class="post-metadata">

**Author:** ![Mike\_Charlesworth](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/958977/32.png) [@Mike\_Charlesworth](https://forum.xojo.com/u/Mike_Charlesworth)\
**Post date:** [July 14, 2014, 10:49pm UTC](https://forum.xojo.com/t/folderitem/17957/3 "2014-07-14T22:49:04Z")

</div>

I may have to but i’m not a fan, even the syntax bothers me. Try this, if it goes wrong do this instead.

If I do: `Dim f as folderitem([i][invalid path][/i])` it works fine. There is some kind of inconsistency here that

Dim f as new FolderItem([invalid path],FolderItem.PathTypeNative) Is trying to resolve the path when declared whereas

Dim f as new folderitem([invalid path]) is not trying to resolve the path when declared.

---

<div class="post-metadata">

**Author:** ![Roger\_Clary](https://forum.xojo.com/letter_avatar_proxy/v4/letter/r/eada6e/32.png) [@Roger\_Clary](https://forum.xojo.com/u/Roger_Clary)\
**Post date:** [July 15, 2014, 1:13am UTC](https://forum.xojo.com/t/folderitem/17957/4 "2014-07-15T01:13:54Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 5:19pm UTC](https://forum.xojo.com/t/folderitem/17957/5 "2020-10-29T17:19:53Z")

</div>


