New topic: trouble creating folder
<http://forums.realsoftware.com/viewtopic.php?t=26250> Page 1 of 1 [ 8 posts ] Previous topic | Next topic Author Message azrael2000 Post subject: trouble creating folderPosted: Thu Jan 29, 2009 6:26 pm Joined: Fri Oct 13, 2006 3:18 pm Posts: 195 Hi All. I have run into a little issue, that hopefully someone can help me with. I am running Realbasic 2008 v2 on a Macintosh PowerPC. I want to have a folder created for documents a user is entering. If the customer name is "fred", it will create in another folder called "flintstones" a folder named "fred". On a Mac, this line works just fine: f2 = getfolderitem("flintstone").child(wMain.edtcustomer.text) On a windows machine, it crashes. How can I get the folder created in Windows? Regards Top npalardy Post subject: Re: trouble creating folderPosted: Thu Jan 29, 2009 6:37 pm Joined: Sat Dec 24, 2005 8:18 pm Posts: 4347 Location: Canada, Alberta, Near Red Deer You probably need to create it in a place the user has privileges to create folders On Windows the user likely does not have privileges to do this On both I would use SpecialFolders.ApplicationData _________________ My web site Great White Software RBLibrary.com REALbasic learning Top timhare Post subject: Re: trouble creating folderPosted: Thu Jan 29, 2009 7:44 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 4269 Location: Portland, OR USA What is the error message? If "flintstone" does not yet exist, you'll get a NilObjectException. Tim Top azrael2000 Post subject: Re: trouble creating folderPosted: Thu Jan 29, 2009 8:42 pm Joined: Fri Oct 13, 2006 3:18 pm Posts: 195 Hi there. Thank you very much for the replies. I don't think I can use the SpecialFolder.Application data as the user will want to go back into them to pull out the documents they are storing. Also, on the windows machine I am testing on, the account has administrator privileges. So you figure if it was a question of the privileges, shouldn't the folder be created? Regards Top timhare Post subject: Re: trouble creating folderPosted: Thu Jan 29, 2009 10:01 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 4269 Location: Portland, OR USA There's nothing in the code you posted that would create the folder. How are you creating it? Or do you assume it already exists? (And does it actually exist on the machine?) Tim Top azrael2000 Post subject: Re: trouble creating folderPosted: Fri Jan 30, 2009 6:43 am Joined: Fri Oct 13, 2006 3:18 pm Posts: 195 Hi Tim Here is the code I am using to determine if the folder exists, and if not, to create it... As I said earlier, the code works on my mac, but not on a Windows machine, on which I have admin access. Which baffles me... <smile> Regards ============= if TargetMacOS then if f2 = nil then MsgBox "No folder found with that name" return else f2 = GetFolderItem("license documents").child(wMain.edtlocn.text) end if else if TargetWin32 then if f2 = nil then MsgBox "No folder found with that name" return else f2 = GetFolderItem("license documents") end if end if end if Top JeremK Post subject: Re: trouble creating folderPosted: Fri Jan 30, 2009 7:54 am Joined: Thu Apr 10, 2008 6:03 am Posts: 93 Location: France If you don't want to use ApplicationData, you could use the Document folder with a folder having the name of your program. Even with administrator privileges, if you are trying to write files in C:\Program Files\ you will get errors. _________________ Current Project: VirtualDJ Skin Editor REALBasic 2008 R4 on Windows Vista. Top mrebar Post subject: Re: trouble creating folderPosted: Fri Jan 30, 2009 8:04 am Joined: Wed Feb 15, 2006 1:30 pm Posts: 2340 Location: U.S.A (often) Spokane, Eugene, Pago Pago Quote:So you figure if it was a question of the privileges, shouldn't the folder be created? No, I don't figure. You must explicitly create each folder in the path if it does not exist, then create the file. See FolderItem.CreateAsFolder and FolderItem.CreateTextFile. Use Tim's suggestion and check FolderItem.LastErrorCode. Michael Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 8 posts ] -- Over 900 classes with 18000 functions in one REALbasic plug-in. The Monkeybread Software Realbasic Plugin v8.1. <http://www.monkeybreadsoftware.de/realbasic/plugins.shtml> [email protected]
