我在LAN网络中连接了4台计算机。我制作了一些文件管理程序。我的问题是,当我访问其他电脑中的某个文件时,我无法获取或设置所有者。我在网上搜索了答案,但没有解决我的问题。可以在其他PC上获取或设置文件的所有者吗?
我试过了:
private void button2_Click(object sender, EventArgs e)
{
OpenFileDialog f = new OpenFileDialog();
f.ShowDialog();
path = f.FileName;
}
private void button1_Click(object sender, EventArgs e)
{
FileSecurity fileS = File.GetAccessControl(path);
SecurityIdentifier secId = WindowsIdentity.GetCurrent().User;
fileS.SetOwner(secId);
fileS.SetAccessRule(new FileSystemAccessRule(secId, FileSystemRights.FullControl, AccessControlType.Allow));
string getOwner = File.GetAccessControl(filepath).GetOwner(typeof(NTAccount)).ToString();
MessageBox.Show(getOwner);
}