gettingstarted
[Top] [All Lists]

Re: Conditional Creation of Files and Folders

To: gettingstarted at lists dot realsoftware dot com
Subject: Re: Conditional Creation of Files and Folders
From: GAmoore at aol dot com
Date: Sat, 29 May 2004 13:10:59 EDT
Delivered-to: gettingstarted at lists dot realsoftware dot com
List-help: <mailto:gettingstarted-request@lists.realsoftware.com?subject=help>
List-id: Getting Started <gettingstarted.lists.realsoftware.com>
List-post: <mailto:gettingstarted@lists.realsoftware.com>
Thanks so much Charles. It works fine!

I put this code in the calling routine :
------------------------------------------------------------------------
   dim theSettingsFolder as FolderItem 
   theSettingsFolder = GetSettingsFolder()
   if theSettingsFolder <> nil then     
     //_____ CREATE FILE __________________
     dlg.InitialDirectory = theSettingsFolder
     dlg.promptText="Enter a filename"
     dlg.SuggestedFileName="Data Export" + d.shortdate + ".txt"
     dlg.Title="Save exported class data as "
     f=dlg.ShowModal()
     If f <> Nil then
       t = f.createtextFile 
      .....................
       t.close


And this (your method) :
------------------------------------------------------------------------------
-
Function GetSettingsFolder 
   dim appFolder as FolderItem
   dim theSettingsFolder as FolderItem
   
   appFolder = GetFolderItem("")
   If appFolder Is Nil or NOT appFolder.Exists then //something really odd 
has happened
     Return Nil
   End if
   
   theSettingsFolder = appFolder.Child("Settings")
   If theSettingsFolder Is Nil then //you may have a permissions problem
     Return Nil
   End if
   
   If theSettingsFolder.Exists then
     If theSettingsFolder.Directory then
       Return theSettingsFolder
     Else   //you could handle this case differently; for instance, you might 
want to alert the user
       Return Nil
     End if
     
   Else   //if it doesn't exist, then try to create it
     theSettingsFolder.CreateAsFolder
     Return theSettingsFolder
   End if
  
_______________________________________________
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>