PDA

View Full Version : shell.GetFolder problem


qwerty
06-11-2007, 01:30 PM
i'm trying to grab the path for the All Users Application Data folder, and then add a hard coded folder and file path to it, so i can check for file existence, however, i'm doing something wrong and keep getting an error

here is my code


appdatacommon = shell.GetFolder(SHF_APPLICATIONDATA_COMMON)
appdatacommon_corrected = String.Replace(appdatacommon, "\\", "\\\\", false);
app_data_common = appdatacommon_corrected .. "\\My_Folder\\My_Sub-Folder" ;


The error i get back is

On Click Line xx: attempt to index global `shell' (a nil value)


where xx is the very first line


can anyone help point me in the right direction please, on my machine app_data_common should equal this string

C:\\Documents and Settings\\All Users\\Application Data\\My_Folder\\My_Sub-Folder



TIA, i will continue searching through the help section and the forum, in the mean time a kick in the right direction would be appreciated

RizlaUK
06-11-2007, 01:33 PM
check your caps

shell.GetFolder

should be

Shell.GetFolder

EDIT:

also why use the string replace ?? am i missing something

this seems to work for me

appdatacommon = Shell.GetFolder(SHF_APPLICATIONDATA_COMMON)
app_data_common = appdatacommon .. "\\My_Folder\\My_Sub-Folder" ;

qwerty
06-11-2007, 01:51 PM
oh man ...... i have been staring at that for about 2 hours and the problem has been staring me in the face all along :rolleyes

i guess what they say about a fresh set of eyes is correct.

and for your question about the string replace, its because later in the project i use the full path for some other stuff, like file transferring, and if i am not mistaken the Shell.GetFolder(SHF_APPLICATIONDATA_COMMON) returns only single "\" which means when i use the path later it will error...... right ?

thank you again for the very speedy reply, boy do i feel stupid right now :o :p

RizlaUK
06-11-2007, 02:38 PM
lol, its true, sometimes its worthwhile to walk away for a short break and things seem clearer on return

and yes, Shell.GetFolder only returns a single backslash but this is only a issue when the path is used in text form (in input or paragraph objects)

iv never needed to amend any of the paths returned by ams functions, you only need to use a double backslash when adding file paths manual

but as i dont know what you intend on doing i could be wrong, im sure you have it in hand

good luck with your project :yes

qwerty
06-11-2007, 03:11 PM
that got it, all works fine now, that little section is part of a much larger section, and yup, there is one particular part that uses the file path in string format, or at least on earlier testing it errored without the double back slashes, now seems to work ok :)

cheers mate, appreciate the help :)