.net

can we lock a directory?

Hello everyone, I am using VSTS 2008 + C# + .Net 3.5 to develop a console application. For file access, we can access file in exclusive mode which blocks other process/thread from access the file -- which has the effect of "lock" the file. I am wondering for directory, are there any built-in API or solution to make the directory exclus...

file enumerate issue

Hello everyone, I am using VSTS 2008 + C# + .Net 3.5 to develop a console application. I need to enumerate the most recent 50 files in current folder (to read file content, to get file meta data like file name, creation time, etc.). Since the current folder has about 5,000 files, and if I use Directory.GetFiles API, all 5,000 files' met...

What tool do you use for testing and developing XPath expressions?

I'd like something similar to Gerry Shaw's regex tool, ... but for XPath. I'd prefer a standalone tool, free, built on .NET, WinForms or WPF. EDIT: I found this one on codeplex, which fits my requirements as stated, but it's sort of feature-free. It doesn't even resize. ...

C# String.Format args

I have an array like this: object[] args and need to insert those args in a string, for example: str = String.Format("Her name is {0} and she's {1} years old", args); instead of: str = String.Format("Her name is {0} and she's {1} years old", args[0], args[1]); NOTE: Actually the first line of code worked! But args[1] was missing...

Accessing a WCF-service using Java

I'm developing a web-service using WCF, which I want to access using a client written in Java. I will encode the messages using Protocol Buffers (with Marc Gravell's protobuf-net to be exact). Is this possible to achive or must the client be written in .NET as well? I know that data serialized with Protocol Buffers is binary interopable...

Slice up an image into tiles

Given a loaded Bitmap object. I want to slice up this image into 256x256 tiles and save out each tile as a jpg file. You may think this as a Silverlight Deep Zoom sort task and you'd be right. I've got a solution using WPF but I would prefer a solution that would work in the .NET 2.0 framework. GDI+ is not somewhere I've spent any am...

Entity Framework: Unable to register the build provider in Web.Config

I am getting this error message when ever I try to update or save my Entity Data Model: ERROR: Unable to register the build provider in Web.Config because of the following exception: 'Object reference not set to an instance of an object.'. Then when I try to run the application I get: The specified named connection is either not foun...

Why same dll exposes different classes in C# and .net

I am using a third party .Net dll in my code and when I add a reference to this dll from a VB.Net application it shows different classes in intellisense and object browser than when I use it in a C# project. Why is there this difference? Edit If designer intended it that way I'd like to know how to do it in my own dlls. ...

How do I tell what an UnsafeNativeMethods.DispatchMessageA call is doing using windbg?

I have tracked down my deadlock to this thread not pumping messages anymore, but how do I take it one step further and figure out what the thread is currently doing? I'm using windbg and random walks using !do hasn't given me anuthing so far many thanks Oskar 0:057> !clrstack OS Thread Id: 0x17f8 (57) ESP EIP 1393f1ac 2070a...

PInvoke CreateDesktop

Hi, I am trying to PInvoke CreateDesktop in a way that passes the flag to inherit the desktop by child processes. The declaration is as follows: [DllImport("user32", EntryPoint = "CreateDesktopW", CharSet = CharSet.Unicode, SetLastError = true)] public static extern IntPtr CreateDesktop(string lpszDesktop, IntPtr lpszDevice, In...

User Control Events and Overrides

I have a User Control for typical CRUD like actions on my WinForm app. Validate, Insert, Update, Clear, Cancel, and Delete. On every form I put this on I end up adding the click event, ucPersonNav.btnValidate.Click += new EventHandler(btnValidate_Click);, for every button. What I am wondering is can I have the Events be on the User C...

Force external process to be killed after time period

I have a command line executable that is run from a C# class library. In some very rare situations the executable will hang because of the command line data passed to it. Unfortunetely this causes the application calling the c# DLL to hang whilst it waits indefinitely for the process to exit. If the command line exe doesnt finish execut...

How do I find the position / location of a window given a hWnd without NativeMethods?

I'm currently working with WatiN, and finding it to be a great web browsing automation tool. However, as of the last release, it's screen capturing functionality seems to be lacking. I've come up with a workable solution for capturing screenshots from the screen (independently generating code similar to this StackOverflow question) in ...

C# - List<T>.Remove() always deletes the first object on the list

Working in Visual Studio 2008 (C#)... I use a List collection to store instances of my custom class (Shift). I want to delete a certain shift from the list by using the Remove method. But List.Remove() always deletes the first item it finds. I've implemented the IComparable interface for my Shift, I thought this would be enough, then...

Question about TimeZones and Jquery CountDown plugin

Hi I am looking to use this plugin: http://keith-wood.name/countdown.html but I need to use the TimeZone feature of it. So I was looking at the sample code $('#sydneyCountdown').countdown({until: liftoffTime, timezone: +10}); so +10 is the TimeOffSet number. Now I need to make it so I can do a jquery get request and grab the TimeOf...

In System.Windows.Forms.RichTextBox, how to convert from LineNumber to character position?

I would like the converse of RichTextBox.GetLineFromCharIndex() I have a line number and I want to retrieve the char index for that line. The method might be called RichTextBox.GetCharIndexFromLine(). Is it possible, simply? ...

Calling .NET assembly using Xslt from Delphi 5 Win32 assembly.

This is my first attempt to call a .NET assembly from a Delphi 5 (Win32) native assembly. I am only familiar with C# and .NET so please bear with me. I guess I will walk thru this layer by layer. Here is the code for the C# assembly I am attempting to execute from the Delphi 5 assembly. using System; using System.Collections.Generic; us...

ASP.NET MVC DropDownList Selected Value Problem

I have read a ton about this problem, but I cannot figure it out. I have a dropdownlist on my view that is used for paging. You choose the page you want to go to and the form gets submitted. When the view is returned, the requested page is shown. The dropdownlist changes to reflect the newly shown page. This is working fine. My problem...

C#, Copy one bool to another (by ref, not val)

Hi folks. I am at a brick wall here. Is it possible to copy one bool to the ref of another. Consider this code . . . bool a = false; bool b = a; b is now a totally seperate bool with a value of false. If I subsequently change a, it will have no effect on a. Is it possible to make a = b by ref ?How would I do that ? M...

Using Singleton vs Single Call in .NET Remoting?

Up until this point all the .NET remoting code I have written or worked with has been exposed as SingleCall. I ran across a .NET remoting component hosted in a Windows service that is exposed as a Singleton. This object has the potential to be called by more than one client at the same time, and it has no locks or other provisions to p...