I wrote a quick console app in VS2010 to copy a file from a network location to a specified location on disk. The program works fine on Windows but when I copy it into the Mac and execute it against the Mono runtime, it seems to have trouble opening the network share.
My code to create a DirectoryInfo object looks like this:
var dir = new DirectoryInfo(@"\\nameofserver\location\to\file");
In Windows, this resolves correctly to the network share. In Mac, it gives me a relative path to the binary (I was running it from the Desktop):
/Users/username/Desktop/\\nameofserver\location\to\file
I did Google it a little开发者_如何学编程 bit and it suggested that my path should be of the form smb://...
. However, even when I do this, my DirectoryInfo
resolves to:
/Users/username/Desktop/smb://nameofserver/location/to/file
I'm guessing there is either a syntax I'm missing to be able to get access to the network share or that it isn't so straightforward on OSX. Either way, I'd like to know how to connect to the network share and download the file.
Thanks!
EDIT:
I tried //nameofserver/location/to/file
. This helped somewhat, except that it still did not resolve the network share reference, instead assuming the path to be a local one:
/nameofserver/location/to/file
精彩评论