Tag: 文件 权限

FileSystemWatcher – 目标目录所需的最小权限?

使用.NET FileSystemWatcher http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx监视一个充满文件的目录:Changed; 创建; 删除; 重命名事件。 运行FileSystemWatcher的帐户对其正在观看的目录所需的权限最小的是什么? 它似乎是READ,但我无法在任何地方找到记录。 谢谢

设置目录和子项的权限

我的程序复制一些目录,子目录和文件从服务器到本地计算机。 我需要,每个本地用户都可以修改它(编辑/删除/删除/重命名)。 但现在它只能做主人。 如何为复制的目录及其子项设置必要的权限? 我尝试这样的代码: String account = Path.Combine(Environment.MachineName, “Users”); FileSystemRights rights = FileSystemRights.FullControl; AccessControlType controlType = AccessControlType.Allow; DirectorySecurity security = local_commonDir.GetAccessControl(AccessControlSections.Access); FileSystemAccessRule rule = new FileSystemAccessRule(account, rights, controlType); security.AddAccessRule(rule); local_commonDir.SetAccessControl(security); 但是我得到了例外: 某些或属性的链接无法转换。 如果我添加缺少访问控制,则不存在错误。 我认为因为“用户”已经存在而收到错误。 如何改变现有权利?

我可以从运行在其上的Web API应用程序将文件写入服务器计算机上的文件夹吗?

我在我的Web API应用程序中使用此代码来写入CSV文件: private void SaveToCSV(InventoryItem invItem, string dbContext) { string csvHeader = “id,pack_size,description,vendor_id,department,subdepartment,unit_cost,unit_list,open_qty,UPC_code,UPC_pack_size,vendor_item,crv_id”; int dbContextAsInt = 0; int.TryParse(dbContext, out dbContextAsInt); string csvFilename = string.Format(“Platypus{0}.csv”, dbContextAsInt); string csv = string.Format(“{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12}”, invItem.ID, invItem.pksize, invItem.Description, invItem.vendor_id, invItem.dept, invItem.subdept, invItem.UnitCost, invItem.UnitList, invItem.OpenQty, invItem.UPC, invItem.upc_pack_size, invItem.vendor_item, invItem.crv_id); string existingContents; using (StreamReader sr = new StreamReader(csvFilename)) { existingContents = sr.ReadToEnd(); } […]