我刚刚注意到结果的返回列表限制为1000.我的域(HUGE域)中有超过1000个组.如何获得超过1000条记录?我可以从以后的记录开始吗?我可以将其剪切成多次搜索吗?
这是我的查询:
DirectoryEntry dirEnt = new DirectoryEntry("LDAP://dhuba1kwtn004");
string[] loadProps = new string[] { "cn", "samaccountname", "name", "distinguishedname" };
DirectorySearcher srch = new DirectorySearcher(dirEnt, "(objectClass=Group)", loadProps);
var results = srch.FindAll();
Run Code Online (Sandbox Code Playgroud)
我试过设置srch.SizeLimit = 2000; ,但这似乎不起作用.有任何想法吗?
有没有简单的方法来创建一个使用的类 IFormatProvider它写出一个用户友好的文件大小?
public static string GetFileSizeString(string filePath)
{
FileInfo info = new FileInfo(@"c:\windows\notepad.exe");
long size = info.Length;
string sizeString = size.ToString(FileSizeFormatProvider); // This is where the class does its magic...
}
Run Code Online (Sandbox Code Playgroud)
它应该导致字符串格式化为" 2,5 MB "," 3,9 GB "," 670字节 "等等.
我刚刚将另一个项目页面及其dll集成到我现有项目的Bin /文件夹中.我的项目框架是3.5.当我尝试构建项目或解决方案时,它会抛出以下错误:
"类型'ASP.global_asax'存在于'c:\ Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\timesheet\15a75c54\898b48b9\assembly\dl3\58b062b2\00ceda54_c98cc801\App_global.asax .DLL'和'c:\ Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\timesheet\15a75c54\898b48b9\App_global.asax.q_h6dbfx.dll'c:\ Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\timesheet\15a75c54\898b48b9\App_Web_admin.master.fdf7a39c.zecazgwd.0.cs"
将"batch = false"设置为web.config是行不通的.我还试图删除"c:\ Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files \"中的所有文件夹,然后清理并重建灵魂.但它仍然无法正常工作.
如何UserControl在C#/ WPF(.NET 3.5)中将自定义显示为对话框?
我有一段时间写的功能(对于.NET 3.5),现在我已升级到4.0
我无法让它发挥作用.
功能是:
public static class MemoryAddress
{
public static string Get(object a)
{
GCHandle handle = GCHandle.Alloc(a, GCHandleType.Pinned);
IntPtr pointer = GCHandle.ToIntPtr(handle);
handle.Free();
return "0x" + pointer.ToString("X");
}
}
Run Code Online (Sandbox Code Playgroud)
现在,当我调用它时 - MemoryAddress.Get(新车("蓝色"))
public class Car
{
public string Color;
public Car(string color)
{
Color = color;
}
}
Run Code Online (Sandbox Code Playgroud)
我收到错误:
对象包含非原始或非blittable数据.
为什么它不再起作用了?
我现在如何获取托管对象的内存地址?
我正在寻找不区分大小写的替换函数的任何实现.例如,它应该像这样工作:
'This iS IIS'.replaceAll('is', 'as');
Run Code Online (Sandbox Code Playgroud)
结果应该是:
'Thas as Ias'
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
提前致谢.
更新:
将它与变量一起使用会很棒:
var searchStr = 'is';
'This iS IIS'.replaceAll(searchStr, 'as');
Run Code Online (Sandbox Code Playgroud) 我正在使用IIS Express来部署MVC4应用程序.该网站在同一台计算机上运行完美.但在Lan,它给了我错误401.
<authentication mode="Forms">
<forms loginUrl="~/" slidingExpiration="true" timeout="20">
</forms>
</authentication>
Run Code Online (Sandbox Code Playgroud)
在家庭控制器
[HttpPost]
[AllowAnonymous]
public ActionResult Index(LoginModel model, string returnUrl)
{
}
Run Code Online (Sandbox Code Playgroud)
我在管理员模式下从命令提示符启动IIS服务器.IIS以错误响应请求401.
任何线索?
我有HashSet参数的方法.我需要在其中做不区分大小写的包含:
public void DoSomething(HashSet<string> set, string item)
{
var x = set.Contains(item);
...
}
Run Code Online (Sandbox Code Playgroud)
是否可以使现有的HashSet不区分大小写(不创建新的)?
我正在寻找具有最佳性能的解决方案.
编辑
包含可以多次调用.因此,由于性能低于本机HashSet Contains方法,IEnumerable扩展对我来说是不可接受的.
解
既然,回答我的问题是NO,那是不可能的,我已经创建并使用了以下方法:
public HashSet<string> EnsureCaseInsensitive(HashSet<string> set)
{
return set.Comparer == StringComparer.OrdinalIgnoreCase
? set
: new HashSet<string>(set, StringComparer.OrdinalIgnoreCase);
}
Run Code Online (Sandbox Code Playgroud) 使用dapper,我如何插入C# List数据库.以前没有dapper我使用下面的代码将List值插入数据库.
try
{
connection.Open();
for (int i = 0; i < processList.Count; i++)
{
string processQuery = "INSERT INTO PROCESS_LOGS VALUES (@Id, @st_Time, @ed_Time, @td_Time)";
command = new SqlCommand(processQuery, connection);
command.Parameters.Add("Id", SqlDbType.Int).Value = processList[i].ID;
command.Parameters.Add("st_Time", SqlDbType.DateTime).Value = processList[i].ST_TIME;
command.Parameters.Add("ed_Time", SqlDbType.DateTime).Value = processList[i].ED_TIME;
command.Parameters.Add("td_Time", SqlDbType.DateTime2).Value = processList[i].TD_TIME;
dataReader.Close();
dataReader = command.ExecuteReader();
}
connection.Close();
}
catch (SqlException ex)
{
//--Handle Exception
}
Run Code Online (Sandbox Code Playgroud)
我熟悉使用dapper获取数据,但这是我第一次尝试使用插入查询.
我尝试了以下代码,使用Exceute链接查询但坚持循环; 我认为使用dapper工具,不需要循环语句.
connection.Execute(processQuery ... …Run Code Online (Sandbox Code Playgroud) 我是WCF的新手,想知道以下每个绑定的差异/优点/限制/等等:
net.pipe
net.tcp
http
Run Code Online (Sandbox Code Playgroud)
关于何时使用每个绑定和其他示例的支持场景将不胜感激.
c# ×7
.net ×5
asp.net ×2
asp.net-mvc ×1
dapper ×1
dll ×1
filesize ×1
formatting ×1
hashset ×1
iis ×1
javascript ×1
sql-server ×1
wcf ×1
wcf-binding ×1
wpf ×1