这是从listview中取消阻止任何网站的一些代码,但现在我想要取消阻止之前被阻止的网站.我怎样才能做到这一点?
String path = @"C:\Windows\System32\drivers\etc\hosts";
StreamWriter sw = new StreamWriter(path, true);
String sitetoblock = "\n 127.0.0.1 http://"+listView1.SelectedItems[0].Text+"";
sw.Write(sitetoblock);
sw.Close();
MessageBox.Show(listView1.SelectedItems[0].Text " blocked");
Run Code Online (Sandbox Code Playgroud) 鉴于两个相同模式的数据库,有没有简单的方法在两者之间传输记录?我正在使用LINQ to SQL,因为我需要在此过程中执行一些额外的操作,并且使用表示我正在传输的记录的对象使这更容易.这是一个小规模的帮助应用程序,因此SSIS可能有点过分,SQLBulkCopy不允许我在途中轻松查询对象.
我想做的是:
public static void TransferCustomer
(DBDataContext DCSource,
DBDataContext DCDest,
int CustomerID)
{
Customer customer;
using (DCSource = new DBDataContext(SourceConnStr))
{
customer = DCSource.Customers
.Where(c => c.CustomerID == CustomerID)
.Single();
}
using (DCDest = new DBDataContext(DestConnStr))
{
DCDest.Customers.InsertOnSubmit(customer);
DCDest.SubmitChanges();
}
}
Run Code Online (Sandbox Code Playgroud)
但是由于显而易见的原因,这会引发消息异常:
已尝试附加或添加非新的实体,可能已从另一个DataContext加载.这不受支持.
我可以通过像这样对象的浅拷贝来解决这个问题:
public static Customer Clone(this Customer customer)
{
return new Customer()
{
Name = customer.Name,
Email = customer.Email
etc...
};
}
Run Code Online (Sandbox Code Playgroud)
然后插入克隆的项目.如果我只复制有问题的字段,而不是任何表示表关系的引用,这可以正常工作.然而,它有点啰嗦,我正在做的方式需要我手动分配克隆方法中的每个字段.任何人都可以建议任何使这更容易的方法吗?我想知道的两件事是:
非常感谢!
我在SSRS 2008报告中有一个Tablix.它有两级行分组,我希望最左边分组的值继续显示在每一行上.我知道了:
group1 subgroup1 500.00
subgroup2 250.00
Run Code Online (Sandbox Code Playgroud)
......但我更喜欢......
group1 subgroup1 500.00
group1 subgroup2 500.00
Run Code Online (Sandbox Code Playgroud)
我似乎无法找到这个选项.想要一件奇怪的事吗?
比尔谢谢你
我在某处读到,在创建HTML电子邮件时,您应该使用基于表格的布局.您不应该关心创建无表格的基于CSS的布局.真的吗?我必须为我的公司创建一个简报布局,但我不觉得写3个嵌套表很舒服.
public class testtype
{
private int a;
private double b;
testtype(int a,double b)
{
this.a=a;
this.b=b;
}
public void maketoequal(testtype oo)
{
oo.a=this.a;
oo.b=this.b;
}
void trytoequal(int c)
{
c=this.a;
}
public static void main(String[] args)
{
testtype t1,t2;
t1=new testtype(10,15.0);
t2=new testtype(5,100.0);
t1.maketoequal(t2);
System.out.println("after the method is called:"+"\n"+"the value of a for t2 is:"+t2.a
+"\n"+"the value of b for t2 is :"+t2.b);
int c=50;
t1.trytoequal(c);
System.out.println("the value of c after the method be called is:"+c);
}
}
Run Code Online (Sandbox Code Playgroud)
为什么c没有改变?
我正在尝试使用Apache的.htaccess文件缓存一些文件.我想缓存一个特定的文件夹比其他任何东西都长,所以我一直在尝试使用FilesMatch指令,如下所示:
<FilesMatch "skins(.*)\.(jpg|png|gif)">
ExpiresDefault A2592000
</FilesMatch>
我希望能够将所有图像文件缓存在/ skins /目录及其子目录中.但是,我无法完全使用正则表达式--Aracle只是完全忽略它.
如何匹配<FilesMatch>.htaccess文件中的文件夹?
干杯,
马特
我有两个类和一个界面
interface IVehicle
{
void Drive();
}
class Benz :IVehicle
{
public void Drive()
{
Console.WriteLine("WOW! driving benz");
}
}
class Ferrari : IVehicle
{
public void Drive()
{
Console.WriteLine("WOW! driving ferrari");
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个使用它的Driver类.
class Driver
{
public void StartDriving(IVehicle vehicle)
{
vehicle.Drive();
}
}
Run Code Online (Sandbox Code Playgroud)
还有一个通用的驱动程序.
class GenericDriver
{
public void StartDriving<T>() where T : IVehicle , new()
{
T vehicle = new T();
vehicle.Drive();
}
}
Run Code Online (Sandbox Code Playgroud)
问题
有什么想法吗?
目前,我所拥有的唯一信息是浏览器状态栏中的单行错误消息.
你知道如何获得堆栈跟踪吗?
我正在寻找Collaborative RegEx网站或软件,在那里可以提交几个"匹配"和"不匹配"的案例,然后其他人可能会重构正则表达式.喜欢refactormycode.com,但有RegEx扭曲.通过这种方式,可以根据给定的匹配测试查看哪些代码执行速度更快,实际上是正确的.
这可以作为任何人都可以编辑(如维基)或团队内的网站非常有用.
我一直在想这个,对我来说很有意义.有这样的网站/软件吗?如果不是,那么,为什么不呢?
c# ×3
java ×2
regex ×2
.htaccess ×1
apache ×1
applet ×1
c++ ×1
css ×1
debugging ×1
file-io ×1
generics ×1
hosts ×1
html ×1
linq-to-sql ×1
math ×1
mod-expires ×1
newsletter ×1
refactoring ×1
sql-server ×1
ssrs-2008 ×1
templates ×1
w3c ×1