New topic: 

Creating Folder and Folder within Folder problems

<http://forums.realsoftware.com/viewtopic.php?t=47741>

         Page 1 of 1
   [ 3 posts ]                 Previous topic | Next topic          Author  
Message        nilesmitchell          Post subject: Creating Folder and Folder 
within Folder problemsPosted: Mon Apr 29, 2013 8:29 pm                         
Joined: Mon Jan 17, 2011 4:51 pm
Posts: 131                Can't seem to figure this one out.  I'm wanting to 
create a folder, and then another folder within that folder.  Should be simple 
and straight forward.

dim dir as FolderItem
dim dir2 as FolderItem
dir= SpecialFolder.ApplicationData.Child("My Great App")
dir2= SpecialFolder.ApplicationData.Child("My Great App").Child("temp")

dir.CreateAsFolder
dir2.CreateAsFolder


If the parent folder, "My Great App" exists, then the temp folder is created 
within it.

If the parent folder is not there, it gets created but the program crashes with 
a NilObjectException on line "dir2.CreateAsFolder"

Any ideas?   
                             Top                npalardy          Post subject: 
Re: Creating Folder and Folder within Folder problemsPosted: Mon Apr 29, 2013 
8:36 pm                       Real Software Engineer          
Joined: Sat Dec 24, 2005 8:18 pm
Posts: 7793
Location: Canada, Alberta, Near Red Deer                nilesmitchell 
wrote:Can't seem to figure this one out.  I'm wanting to create a folder, and 
then another folder within that folder.  Should be simple and straight forward.

dim dir as FolderItem
dim dir2 as FolderItem
dir= SpecialFolder.ApplicationData.Child("My Great App")
dir2= SpecialFolder.ApplicationData.Child("My Great App").Child("temp")

dir.CreateAsFolder
dir2.CreateAsFolder


If the parent folder, "My Great App" exists, then the temp folder is created 
within it.

If the parent folder is not there, it gets created but the program crashes with 
a NilObjectException on line "dir2.CreateAsFolder"

Any ideas?

Change the order to something like
In your code dir2 may be nil if My Great App doesn't exist

dim dir as FolderItem
dim dir2 as FolderItem
dir= SpecialFolder.ApplicationData.Child("My Great App")
dir.CreateAsFolder

dir2= SpecialFolder.ApplicationData.Child("My Great App").Child("temp")
dir2.CreateAsFolder
      
_________________
Norman Palardy (Real Software)  
                             Top                nilesmitchell          Post 
subject: Re: Creating Folder and Folder within Folder problemsPosted: Mon Apr 
29, 2013 8:45 pm                         
Joined: Mon Jan 17, 2011 4:51 pm
Posts: 131                Thanks, Norman!

That did it!   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 3 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to