C# CreateSymbolicLink 不遵循共享访问 [英] C# CreateSymbolicLink doesn't follow through share access

查看:80
本文介绍了C# CreateSymbolicLink 不遵循共享访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定这只是 C# 问题还是 Windows 限制.

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.

我已经检查了链接的 acl 和目标文件.每个人都应该能够访问.

I already checked the acl of the link and the target files. Everyone should be able to access.

我使用以下函数:

[DllImport("kernel32.dll")]
static extern bool CreateSymbolicLink(string lpSymlinkFileName, string lpTargetFileName, int dwFlags);

也许我只需要设置一些额外的东西?还是我必须更改服务器上的某些 Windows 设置?

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.

编辑 1:

我有共享:C:\share

I have the share: C:\share

链接:C:\share\file.txt

A link: C:\share\file.txt

到目的地:D:\file.txt

to the destination: D:\file.txt

如果我从另一台电脑访问共享,我将无法访问 file.txt 的数据.

If I access the share from a different pc I can't access the data of file.txt.

推荐答案

来自 Tuxera 的这个页面有一个很好的 原因描述

This page from Tuxera has a good description of the reason

Windows 中也有类似的符号链接概念远景.符号链接可以重定向到文件或目录由绝对或相对路径定义.在遥控器上定义时文件系统,它们在本地系统上处理,而目录联结在文件服务器上处理,这使得文件服务器无法访问目标时的区别.

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.

CreateSymbolicLink 函数将创建一个将由客户端解释的链接.所以客户端计算机(不是服务器)试图访问一个名为 d:\file.txt 的文件,该文件当然不存在于客户端.

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.

对于 windows 连接或 Reparse Point 将在像您的示例一样的服务器上工作.在代码之外创建一个的最简单方法是使用 SysInternals 连接工具.

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.

这篇关于C# CreateSymbolicLink 不遵循共享访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆