How to copy a file so it creates missing folders in the path

Klaus major-k klaus at major-k.de
Fri May 10 04:54:04 EDT 2013


Hi Tom,

Am 10.05.2013 um 01:39 schrieb tbodine <lvhdgc7 at gmail.com>:

> Hi,
> 
> I'm working on a Win/Mac application and trying to copy a Preferences stack
> from the defaultFolder to Application Data with a unique folder there to
> house it. I build a path, including the folder name, but revCopyFile
> silently fails every time. If I remove the desired folder from the path, it
> works but leaves my file loose in the top level App Data folder. Is there a
> way to do this that creates any missing folders in the path?
> 
> My code is:
> 
> if gOS contains "Mac" then
>    put specialFolderPath("asup") into tPath
> else
>   put specialFolderPath(26) into tPath
> end if

put tPath & "/MyFolder/" into gSettingsFolder

> put tPath & "/MyFolder/Settings.rev" into gSettingsPath

## Check for folder and create it if neccessary:
if there is NOT a folder gSettingsFolder then
   create folder gSettingsFolder
end if

## Target file can be named whatever you like!
> put "CustomSettings.rev" into tSourceFile
> revCopyFile tSourceFile, gSettingsPath
...
> 
> When I have the folder name in the path, this fails. If I remove it, it
> works. (I'm also changing the name of the stack file during the copy
> process, but don't think that matters.)
> 
> Thanks!
> Tom Bodine

Best

Klaus

--
Klaus Major
http://www.major-k.de
klaus at major-k.de





More information about the use-livecode mailing list