|
|||
|
Hi,
I'm using inet.getUrl(serverFile, localFile) to download a file. The local path does not yet exist, so there's an error. How can I create the subfolder(s) where the file has to be created? Is there a way to extract the path of the string "localFile" and to create the folder? tnx, Gert |
|
|||
|
It's becomming a habit: I found a solution myself
![]() here's what I did: //convert double slashes to backslash var tmp = localFile.split("//").join("\\") tmp = tmp.split("\\") //remove file name (remaining part = path) tmp.pop() var subPath = tmp.join("\\") trace(">>>>"+ subPath) if (!Folder.exists(subPath)) { new Folder(subPath); trace(">>CREATED: " + subPath) } |
|
|||
|
Code:
function createFolder(pathName)
{
pathName = pathName.split("/").join("\\");
var items = pathName.split('\\');
var name = '';
for (var i = 0; i < items.length; i++)
{
name = name + items[i] + '\\';
if (!Folder.exists(name))
{
new Folder(name);
}
}
}
createFolder("c:/hello\\world/one\\two/three");
|
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|