问题
I'm not sure if this is just a C# problem or a windows limitation.
I have a server running my program which makes symbolic links in a shared folder. I can access through this link form the server with a normal disk path and the share path.
If I try to access the same share with an other pc I can't access the linked files. I do can delete rename... the links but I can't follow the links.
I already checked the acl of the link and the target files. Everyone should be able to access.
I use the following function:
[DllImport("kernel32.dll")]
static extern bool CreateSymbolicLink(string lpSymlinkFileName, string lpTargetFileName, int dwFlags);
Maybe I just have to set some additional things? Or do I have to change some windows settings on the server?
Sorry if the solution is not a programming thing but I think here I have the best chances to get help with this.
Edit 1:
I have the share: C:\share
A link: C:\share\file.txt
to the destination: D:\file.txt
If I access the share from a different pc I can't access the data of file.txt.
回答1:
This page from Tuxera has a good description of the reason
The similar concept of symbolic link is also available in Windows Vista. The symbolic links can redirect to a file or a directory defined by an absolute or a relative path. When defined on a remote file system, they are processed on the local system, whereas the directory junctions are processed on the file server, which makes a difference when the target is not accessible by the file server.
The CreateSymbolicLink function will create a link that will be interpreted by the client. So the client computer (not the server) is trying to access a file with the name d:\file.txt which of course does not exist on the client.
For windows a Junction or Reparse Point will work on a server like your example. The easiest way to create one outside of code is to use the SysInternals Junction tool.
来源:https://stackoverflow.com/questions/4492677/c-sharp-createsymboliclink-doesnt-follow-through-share-access