Tag: 文件权限

将文件复制到我没有权限的目录(c:或c:程序文件)

可能重复: 允许访问权限在Windows 7的Program Files中写入 好的,这是我的代码: System.IO.File.WriteAllBytes(path1, path2); 但是,有一个问题。 用户(Windows 7用户没有权限将文件复制到c:默认情况下)(…我的意思是程序…)因此,程序失败。 如果用户允许在c中复制文件:程序运行正常。 但你不能告诉每个用户“去许可……….”所以我怎样才能让用户将我的文件复制到c://

WinSCP .NET程序集 – 如何在创建目录后设置文件夹权限?

我正在构建一个网站,我希望当用户注册时,在SFTP服务器上创建一个目录并在该目录中放入一个新文件 我正在使用WinSCP .NET程序集,并编写C#。 我注意到你只能在方法中设置权限: Session.PutFiles而不是在方法中: Session.CreateDirectory 在我创建目录并将文件放入其中之后,我无法访问该文件,因为我没有权限 – 我正在使用完整的URL访问该文件 我该如何访问该文件? PS。 当我手动更改目录权限时,我可以访问该文件。

如何在通过Amazon s3 API上传时设置文件权限

有没有办法在通过Amazon S3 API上传文件时设置文件权限。 在我目前的解决方案中,我能够将文件上传到我的存储桶,但我无法通过文件属性部分中提到的URL查看该文件。 当我在查询字符串中传递访问键时它正在打开。 是否需要在Amazon S3中进行任何设置,或者我需要在上载时为所有文件设置权限。 提前致谢。 Kamal Kant Pansari

重复GetAccessRules,FileSystemAccessRule条目

我从以下代码中获取了一个重复的FileSystemAccessRule: C:\inetpub\wwwroot\AspInfo\Account BUILTIN\IIS_IUSRS : Allow : ReadAndExecute, Synchronize BUILTIN\IIS_IUSRS : Allow : -1610612736 NT SERVICE\TrustedInstaller : Allow : FullControl NT SERVICE\TrustedInstaller : Allow : 268435456 我无法弄清楚它是什么或为什么。 并且显示的权限与我可以看到的文件FileManager属性不匹配。 例如,如何从此迭代或类似迭代中找到“列出文件夹内容”权限。 如果有人知道.NET文档中的示例,那将会有所帮助。 protected void directoryInfo() { var di = new DirectoryInfo(Server.MapPath(“/”)); foreach (DirectoryInfo dir in di.GetDirectories()) { Response.Write(dir.FullName + “”); DirectorySecurity ds = dir.GetAccessControl(); foreach (FileSystemAccessRule fsar in […]

使用C#以编程方式删除“包含此对象的父级的可inheritance权限”复选框

我在我的应用程序中要求迭代遍历所有子文件夹,以编程方式使用C#删除“包含此对象的父级的可inheritance权限”复选框。 并且还将inheritance的父权限转换并添加为文件夹的显式权限。 任何人都可以告诉我吗? 我怎么能在C#中做到这一点。

如何制作“只读”文件?

我正在使用C# StreamWritier类。 问题: 如何将文件设置为只读,以便没有人可以删除或写入文件? 如何制作隐藏文件? 我正在创建这样的文件: private void button1_Click(object sender, EventArgs e) { SaveFileDialog save = new SaveFileDialog(); save.FileName = textBox1.Text; save.Filter = “Text File | *.rtf”; if (save.ShowDialog() == DialogResult.OK) { StreamWriter writer = new StreamWriter(save.OpenFile()); writer.WriteLine(textBox2.Text); } writer.Dispose(); writer.Close(); }

File.Move不会从目标目录inheritance权限?

如果在创建文件时出现问题,我一直在写一个临时文件,然后移动到目的地。 就像是: var destination = @”C:\foo\bar.txt”; var tempFile = Path.GetTempFileName(); using (var stream = File.OpenWrite(tempFile)) { // write to file here here } string backupFile = null; try { var dir = Path.GetDirectoryName(destination); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); Util.SetPermissions(dir); } if (File.Exists(destination)) { backupFile = Path.Combine(Path.GetTempPath(), new Guid().ToString()); File.Move(destination, backupFile); } File.Move(tempFile, destination); if (backupFile != […]

在C#中设置文件权限

我想在C#中将文件的权限设置为“无法删除”,只能读取。 但我不知道该怎么做。 你能帮助我吗 ?

文件权限不会inheritance目录权限

我有一个程序正在为用户输出创建一个安全的目录。 这是正常的,但我在其中创建的文件(或复制到它)最终只有管理员访问权限。 DirectoryInfo outputDirectory = baseOutputDirectory.CreateSubdirectory(outputDirectoryName, GetDirectorySecurity(searchHits.Request.UserId)); … private DirectorySecurity GetDirectorySecurity(string owner) { const string LOG_SOURCE = “GetDirectorySecurity”; DirectorySecurity ds = new DirectorySecurity(); System.Security.Principal.NTAccount ownerAccount = new System.Security.Principal.NTAccount(owner); ds.SetOwner(ownerAccount); ds.AddAccessRule( new FileSystemAccessRule(owner, FileSystemRights.FullControl, AccessControlType.Allow)); //AdminUsers is a List that contains a list from configuration // That represents the admins who should be allowed foreach (string […]

Windows中有效的文件权限工具的api

从Windows Server 2003开始,Windows包含一个新工具,用于计算用户的有效权限(基本上它可以解析所有组访问权限并处理所有“拒绝”权限)。 一个例子是用户A属于组B和C.B已被拒绝对文件F的读取权限,而C已被允许对文件的读写权限,我想计算用户A具有的有效权限在档案F. 通过右键单击文件并转到属性 – >安全性 – >高级 – >有效权限,可以在Windows Server 2003,Vista,7和Server 2008上使用此工具。 我需要的是C#中的API,它可以完成同样的工作。 最常见的FILE API返回访问规则(类FileAccessRules),但似乎没有直接的方法来从这些访问规则集计算有效权限。 注意:如果可能的话,我不想在代码中处理有效的权限,但我已准备好作为最后的手段。