.net

How to monitor clipboard content changes in C#?

Hi, I want to have this feature in my C# program: When the user do Ctrl+C or Copy anywhere (i.e. when the clipboard content changes), my program will get notified, and check whether the content met certain criteria, if so, become the active program, and process the content, etc. I can get the contents out from System.Windows.Forms.Clip...

Ftp file watcher like SystemFileWatcher in .net?

Hi, In my project I need to watch multiple FTP Folders continuosly, if any new file comes i need pick the filename and do some process. If that is normal Windows/Local File System folder I can achieve this by using SystemFileWatcher of .net. Is there any thing like SystemFilewatcher to watch FTP folders? Thanksnrk ...

Security features of WebBrowser Control

Does the WebBrowser control have any securtiy features included in it? I mean, if i use the WebBrowser control in an application then would using this browser be any more vulnerable than any normal browser, say IE, to securtiy attacks. Does the WebBrowser control share or use security features of IE? ...

Does boxing create garbage in .NET?

Hi! I'm wondering whether boxing a value type in an object is a special case or whether the "box" constructed by .NET becomes garbage (that the GC has to collect) after any references to it are dropped. For example, StringBuilder.AppendFormat() has these overloads: StringBuilder.AppendFormat(string format, object arg0); StringBuilder....

control names in a custom validator .NET Client Side Validation

Hi I have a gridview with three columns of textboxes. It can have as many rows as necessary but its usually only about 5 rows. Each row needs to be validated. I want to create a client side validator that sums 2 of the columns together and compares it with the third column to check that the user has entered the data correctly. Just in...

Check if I can execute some sql-command

I'm using ADO .NET and MS SQL Server 2008. I have a connection object to a server and a command: SqlConnection conn = /* my connection*/; string cmd = "some_sql_command"; I want to check if SQL Server can execute cmd. I don't want to execute cmd, but I want to know If SQL Server can execute it. cmd can be any single SQL statement, i...

How base.ToString() called using callvirt, can lead to a StackOverflow Exception ?

IL offers two statements for calling functions, i.e. call and callvirt. Call is used to call the non-virtual or static functions or any function where compiler doesn't want to do a null check on the reference. callvirt is used to call virtual functions, non-virtual functions are also called, since compiler does a null check on the refer...

Sending information between two Windows Froms in C#

This might be a novice question. :). Consider the following scenario. Suppose we have two windows forms that are already "loaded" (i.e You can see both the forms) Form 1 contains a textbox and a "submit" button while the form 2 contains a text lable. The user can enter a string in the textbox and press ...

Insert character at start of current line (vb.net)

Currently I have the code: textbox1.text = textbox1.text.insert(textbox1.getfirstcharIndexFromCurrentLine(),";") But this means it has to reload the entire textbox, which with large files is noticeable slow. What are the alternatives? ...

wpf method to start the application message loop

Hi All, I need to create a Form in a different thread and keep it ranning until a user performe some action in the main thread (click a button). It is not very difficult to do using System.Windows.Forms.Application.Run(new ApplicationContext()); that starts an application message loop in the current thread. But this solution requir...

Problem with table names in excel with oledb driver ...

I am using Oledb driver to load data from excel for displaying in tabcontrol with datargids I am using following loop to load data from every sheet foreach (string str in sheets) { string query = "SELECT * FROM [" + str + "]"; adapter.SelectCommand.CommandText = query; ...

AutoResetEvent object , waits 60 secs OR event

Im using AutoResetEvent object to block a thread for 60 secs ,, but I would like to block it for 60 secs or AutoResetEvent.set() event CODE : global: private readonly AutoResetEvent _signal = new AutoResetEvent(false); blocking: _signal.WaitOne(60000, true); event to give signal _signal.Set(); but it alwayas waits the whole 60 se...

Can Delegates cause memory leaks?

Can Delegates cause memory leaks? I mean, by e.g. if a class A contains a ADelegate and the latter points to the BMethod (of B class) can this prevent the A class or B class collection by the GC? If so, how can we "free" delegates (setting ADeletate = Nothing / null?) How do you comment this one: //Class A Finalize, containing ADeleg...

Find the distance required to navigate a list of points using linq

Using linq given a IEnumerable of two dimensional points, Find the distance required to navigate all points assuming the points are visited in the order they appear in the list. I thought I might be able to somehow use the .Aggregate<> function but can't figure out how to make it work. The problem is the aggregate returns the same type...

Download file over HTTPS using .NET (part 2)

On a regular basis I have to do the following manually in a web browser: Go to an https website. Logon on a webform. Click a link to download a large file (135MB). I would like to automate this process using .NET. Some days ago I posted this question here. Thanks to a piece of code by Rubens Farias I am now able to perform the above...

Strange SerializationException for Enum in AppDomain

I am getting a SerializationException for an enum when calling from one AppDomain into another: System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Dummy.MyEnum,Dummy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Sample code: public enum MyEnum { A = 0, B = 1, C ...

Log4net - How to know when a file is rolled ?

Hi Everybody, I have a log file created by log4net which changes every hour. Is there a way to know when this roll occurs? Like an event in the log4net lib to which I could bind, and perform an action when this event is fired ? I'm not looking for code samples, just to know if this event exists, and in that case his name. Thanks in adv...

Linq to Entities: adding a where condition to a child relationship

For example I have a list of customers which each have a list of orders. Now, I want to get a list of all customers with unpaid orders (let's say this is status 2). Together with that list of customers, I want to have the list of unpaid orders also. For example I have this: from c in mycontext.Customers.Include("Orders") select c Whe...

Generating .net webservice proxy with svcuril without SoapAuthHeader in method signature

The generated webservice proxyclass for a none wcf .net webservice added an SoapAuthHeader object to every method signature. This is somewhat undesired, since the webservice has no security implemented and the additional argument is unused. Formerly the webserviceproxy was been generated by Visual Studio but since we want to share types...

How to retrieve the creation date of an AD user from .NET?

I'd like to retrieve the creation date of users in Active Directory. I understand that users have a WhenCreated property, but I cannot see that property exposed on the UserPrincipal type I am working with. I'd like to do something like this: var principal = UserPrincipal.FindByIdentity(context, IdentityType.Guid, guid); //var createdDa...