سؤال

I've got an Air application that needs to reference files located in a shared network folder. From within the Air application running on Windows I can access the share through a File object as follows:

var folder:File = new File("file:///\\\\server\\share\\parent_folder\\folder");

On a Mac, that doesn't work, and I can't find any variation on the path that does. I can connect to the server through the Finder using the path "smb://server/share/parent_folder/folder", and then I can construct a File object through some (seemingly) convoluted volume mount with a name that seems to vary depending on how many existing mounts there are to "//server/share" (e.g., "/Volumes/share", "/Volumes/share-1", etc.)

Is there a way from within an Air application to connect to a shared server folder on a Mac, without the user needing to connect through the Finder first? Worst case, is there a way to execute a console command from within Air? Presumably I could then mount the share myself. I can't think of a work-around other than requiring Mac users to first manually connect to the server through the finder, then supply the app with the share path every time they run the app!

Thanks in advance for any workable solution!

هل كانت مفيدة؟

المحلول

If I remember correctly, you have to mount the network path. But a user can mount a network drive and have it reconnect automatically when the user logs in so they don't have to reconnect every time they use your app. Take a look at http://osxdaily.com/2010/09/20/map-a-network-drive-on-a-mac/ which has instructions for automatically connecting.

نصائح أخرى

For Mac issue, use the resolvePath() method of File to reference a file/folder; see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.html#resolvePath()

eg:

var folder:File = File.applicationDirectory.resolvePath("absolute/path/to/folder");

Note that "file:///" should not be used, and slashes should be "/" not "\"

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top