Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-18-2005, 12:44 PM
Member
 
Join Date: Apr 2005
Location: Antwerp, Belgium
Posts: 40
Default get path of unexisting file

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
Reply With Quote
  #2 (permalink)  
Old 04-18-2005, 01:40 PM
Member
 
Join Date: Apr 2005
Location: Antwerp, Belgium
Posts: 40
Default Re:get path of unexisting file

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)
}
Reply With Quote
  #3 (permalink)  
Old 05-16-2006, 10:20 AM
Junior Member
 
Join Date: May 2006
Posts: 1
Default Re:get path of unexisting file

Is it possible this only works when creating one subFolder
we'll probably need a recursife function to create more subFolders

anyone has this function ?
Reply With Quote
  #4 (permalink)  
Old 05-17-2006, 01:59 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:get path of unexisting file

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");
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 07:52 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.