PDA

View Full Version : Intranet shared drive access



mafranks
10-12-2004, 02:53 PM
I have an AMS 5.0 application that gets folder file information from our company's intranet shared drive:

files = File.Find("S:\\SAFETY\\Bulletins", "*.*", false, false, nil);

This worked fine until I discovered that some of our computers have the shared drive mapped as "E" or "T" or some other letter. I cannot request they all remap their computers to "S" for the shared drive as some are already using "S" for some other purpose. Anyway, we have over a hundred computers at our site and I have no idea how many have or do not have "S" mapped as their shared drive.

Does anyone know a way I can rewrite the above code to find the SAFETY folder and it's subfolders no matter which drive letter our 'shared' drive is ID'd to?

One more piece of information. Our shared drive, while using MS explorer, will always be indentified by something like: lnlcc20$ on 'usldcvs(S:). Of course you wold replace the 'S' with 'E' or 'T' or whatever the individual's mapped drive letter would be. Thanks for any help.

Worm
10-12-2004, 03:05 PM
You could use UNC

\\ComputerName\\ShareName

For instance, if the computer name was: Computer1
and the folder was shared as: Safety

You could do this:

files = File.Find("\\\\Computer1\\SAFETY\\Bulletins", "*.*", false, false, nil);

SUF6NEWBIE
10-12-2004, 03:48 PM
Try this (for true mapped Network Drives)

CODE:

Get_Drives_T = Drive.Enumerate(); --function to return all network drives

for drvindex, drives in Get_Drives_T do
drive_type = Drive.GetType(drives);
if (drive_type == 4) then --is a network drive
--the drive letter will be returned as eg: S:\
--add here file.find and or a folder.find actions
--to locate your target id folder\files and you should be all set
--when located add an if statement to break out of loop.
if .... then
break;
end
end
end

end --end of function

hope this helps a little
(having trouble getting the code to show a better layout..sorry)

Worm
10-12-2004, 10:58 PM
SUF6NEWBIE,

You can use
(code)

Your Code block here

(/code)


Substitute square bracket [ ] for the parenthesis ( )




Try this (for true mapped Network Drives)

CODE:

Get_Drives_T = Drive.Enumerate(); --function to return all network drives

for drvindex, drives in Get_Drives_T do
drive_type = Drive.GetType(drives);
if (drive_type == 4) then --is a network drive
--the drive letter will be returned as eg: S:\
--add here file.find and or a folder.find actions
--to locate your target id folder\files and you should be all set
--when located add an if statement to break out of loop.
if .... then
break;
end
end
end

end --end of function

hope this helps a little
(having trouble getting the code to show a better layout..sorry)

SUF6NEWBIE
10-13-2004, 02:58 AM
neat trick WORM...tks --wierd the correct layout would not
transfer to 'forum display' ....some 'tab' issues at my end.

mafranks
10-14-2004, 11:13 AM
Worn's code worked fine. All I had to do was change:

files = File.Find("\\\\Computer1\\SAFETY\\Bulletins", "*.*", false, false, nil);

to:

files = File.Find("\\\\usldcvs1fsh02\\lnlccf20$\\SAFETY\\Bulletins", "*.*", false, false, nil);

Thanks for the help.

Oh, one last question. Why the \\\\ instead of just \\ ???

Thanks

Worm
10-14-2004, 11:21 AM
The first backslash is an escape character to the scripting engine. When it encounters a backslash, it interprets the next character (i.e. \t is equal to tab, \n is a newline). So to have a backslash within your string, you need to double them up because the first one is the escape character, the second one is the actual character. So, to show two backslashes, you must use 4.

or something like that :)

mafranks
10-15-2004, 05:17 AM
Worm, thanks again.