我有一个问题,我需要为所有经过身份验证的用户添加对文件夹的访问权限,以存储与应用程序相关的设置.我发现这可以通过以下代码完成...
var Info = new DirectoryInfo(settingsdir);
var Security = Info.GetAccessControl(AccessControlSections.Access);
Security.AddAccessRule(
new FileSystemAccessRule(
"Authenticated Users", FileSystemRights.Modify,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
PropagationFlags.None,
AccessControlType.Allow));
Run Code Online (Sandbox Code Playgroud)
我发现的问题是"Authenticated Users"是Windows上的系统帐户,但是在Windows的不同语言版本上,此帐户名被翻译,例如在德国,该帐户被称为"Authentifizierte Benutzer".有没有办法知道这个帐户的正确名称(显而易见的是通过每种语言并找到正确的帐户名称).
我似乎无法找到一种一致的方法来创建一个可以跨word,Internet Explorer和chrome工作的分页符.
以下示例(来自Google Chrome打印分页符)将为Chrome和Internet资源管理器正确创建分页符,但在单词中没有分页符.
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title>Paginated HTML</title>
<style type="text/css" media="print">
div.page
{
page-break-after: always;
page-break-inside: avoid;
}
</style>
</head>
<body>
<div class="page">
<h1>This is Page 1</h1>
</div>
<div class="page">
<h1>This is Page 2</h1>
</div>
<div class="page">
<h1>This is Page 3</h1>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
在弄乱了我发现的单词后,您可以通过以下内容添加分页符:
<br style="ms-special-character:line-break;page-break-before:always" />
Run Code Online (Sandbox Code Playgroud)
这里的问题是Internet Explorer也看到这是一个分页符,所以如果你结合使用这些方法,Chrome和Word会正确分页,但Internet Explorer会插入两个分页符.如果你只使用一个,那么chrome和explorer是正确的,而word不是,依此类推.
我们正在从SourceSafe迁移到Subversion作为我们的源代码控制提供商...到目前为止一直进展顺利,除了我可以弄清楚你如何在多个项目之间"共享"一个文件.在sourcesafe中,您创建了一个指向该文件的链接,然后将其添加到您的项目中,然后source safe知道该文件实际上只是一个文件.你如何与Subversion做同等的事情?
我有一个单独的应用程序(用于拼写检查我的.resx文件)作为预构建事件运行.但是,如果.resx文件包含文本文件(例如xml),我的应用程序将加载该文件并尝试拼写检查它.这不是我想要的.有没有办法告诉ResXResourceReader,如果加载的资源实际上是一个文件?
代码示例如下所示:
ResXResourceReader reader = new ResXResourceReader(filename);
ResourceSet resourceset = new ResourceSet(reader);
Dictionary<DictionaryEntry, object> newvalues = new Dictionary<DictionaryEntry, object>();
foreach (DictionaryEntry entry in resourceset)
{
//Figure out in this 'if' if it is an embedded file and should be ignored.
if (entry.Key.ToString().StartsWith(">>") || !(entry.Value is string) || string.Compare((string)entry.Value, "---") == 0)
continue;
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试编写代码来提取CAB文件的内容,但是我在使用SetupIterateCabinet例程时遇到了问题.
请参阅此处的文档http://msdn.microsoft.com/en-us/library/aa377404(v=vs.85).aspx
我可以像这样正确导入它
private const uint SPFILENOTIFY_CABINETINFO = 0x00000010;
private const uint SPFILENOTIFY_FILEINCABINET = 0x00000011;
private const uint SPFILENOTIFY_NEEDNEWCABINET = 0x00000012;
private const uint SPFILENOTIFY_FILEEXTRACTED = 0x00000013;
private const uint SPFILENOTIFY_FILEOPDELAYED = 0x00000014;
private const uint NO_ERROR = 0;
private const uint FILEOP_ABORT = 0;
private const uint FILEOP_DOIT= 1;
private const uint FILEOP_SKIP= 2;
private const uint FILEOP_NEWPATH= 4;
static void Main(string[] args)
{
SetupIterateCabinet("c:\\SomeCab.cab", 0, new PSP_FILE_CALLBACK(CallBack), 0);
Console.ReadKey();
}
[DllImport("SetupApi.dll", CharSet = CharSet.Auto)]
public static extern …
Run Code Online (Sandbox Code Playgroud) 使用属性网格时,如何让它允许我一次为多个对象设置一个属性(当有第二个级别时).如果两个属性具有相同的值,则一切似乎都正常,但如果属性不相等,则propertygrid不会加载子属性(从箭头向右),因此无法设置它们.我创建了以下示例,抱歉代码的长度.
public partial class Form1 : Form
{
public Form1()
{
this.Size = new Size(275, 568);
PropertyGrid grid = new PropertyGrid();
grid.Dock = DockStyle.Fill;
this.Controls.Add(grid);
Control c1 = new Control();
c1.Border.Bottom.Color = Color.Red;
Control c2 = new Control();
c2.Border.Bottom.Color = Color.Red;
Control c3 = new Control();
c3.Border.Bottom.Color = Color.Purple;
//This works as expected
//grid.SelectedObject = c1;
//This works as expected
//grid.SelectedObjects = new object[] { c1, c2 };
//This does not work
grid.SelectedObjects = new object[] { c1, c3 }; …
Run Code Online (Sandbox Code Playgroud) 我将datetime值作为sql float类型(从DateTime.OADate转换)存储在数据库中,原因有很多,但在某些情况下,从数据库中获取一个人类可读的日期/时间列是很好的.我发现我可以执行该语句
SELECT CAST (timerecorded_utc as DATETIME) FROM tablename
Run Code Online (Sandbox Code Playgroud)
它会给我一个我正在寻找的日期时间字符串,但它似乎已经关闭了2天.我意识到我可以修改语句(因为时间表示为双1天= 1.0)
SELECT CAST (timerecorded_utc-2.0 as DATETIME) FROM tablename
Run Code Online (Sandbox Code Playgroud)
但我想知道这是否一致,在我看来,我有一些原因导致我失踪的差异.