.net

VB NET Listing drives and VMWARE

This is a strange one... In a windows forms app (VB.NET/VS 2005) I have the need to occasionally check if the application DVD is inserted. In my production machine (and in the majority of our clients) this code takes less than an second to execute. But in some machines, it takes about 8 to 10 seconds. I couldn't find any common ground on...

Best sorting algorithms for C# / .NET in different scenarios

What are the best algorithms for sorting data in C#? Is there one sorting algorithm that can handle 80% of sorts well? Please give code examples if applicable. ...

Sharepoint 2007 NTLM issue with ASP.NET Web App hosted on Sharepoint server

I'm hosting an ASP.NET web application on a Sharepoint 2007 box, which makes a web service call to Sharepoint to retrieve a document location (specifically, the GetListItems method). The service is consumed with passed credentials of a valid Sharepoint account with appropriate permissions. ListServiceWrapper listService = new ListServi...

Namespace collisions

How is it possible that .NET is finding the wrong 'MyType' in this scenario? I have a type A.B.C.D.MyType in a project that I'm working on, and I'm referencing a DLL that has a type A.B.MyType? I do not have any 'using A.B;' statements anywhere in my code, and I do have 'using A.B.C.D;'. When I compile, the compiler thinks any naked ref...

Can I use dashes in Named Captures with .NET's System.Text.RegularExpressions?

Is it possible to do something like (?'A-B'\s*) ? ...

How to scroll a panel manually?

I want to use the same functionality available when a Panel.AutoScroll is true, but with the scrollbars invisible. To do so I need to know how can I scroll to left/right up/down using functions in my code. ...

Print a tiff file from a .Net Windows Service

Hello to all, We have built an application that receives several files in different formats, pdf, tiff, jpgeg, doc, etc. After received, they are converted to tiff files using a third party printing driver which is installed locally on the server and set up as the default printer. In order to do that we open a System.Diagnostics.Process...

.NET PerformanceCounter for Hard Faults/sec

Vista's Resource Monitor includes a reading for "Hard Faults/sec". Is there an equivalent performance counter I can use in C# to get this reading? I've tried the "Page Faults/sec" under the memory category, but that appears to be something different. ...

IIS 6/.Net 2:How can user A get the user cookie for unrelated user B who is in a different session and on another box?

1) user A goes to the site, creates an account, and logs in 2) user b goes to the site. Rather than having to log in, user b enters as though user b is user a. User b gets access to all of user a's data and can brows the site as user a. Note: user b does not log in. User b just hits the site, and the site returns as if user b is alre...

.net http handler redirect to rtmp and flex

I have an http handler (.ashx) that I use to display an image or swf or flv based on the id. So, for instance http://www.mysite.com/myHandler.ashx?id=1234 displays the image for id 1234. I am using this as a source for an image tag or swfloader or videodisplay in flex. In my handler if the item is a video I just redirect the request to t...

In C#, should I use string.Empty or String.Empty or "" ?

In C#, I want to initialize a string value with an empty string? How should I do this? What is the right way, and why? string willi = string.Empty; or string willi = String.Empty; or string willi = ""; or ? UPDATE Thank you very much for your answers. It seems, that even the easiest questions can start quite interesting dis...

DateTime.UtcNow.Ticks sometimes jumps a remarkable amount

In a tightly looped test application that prints out the value of DateTime.UtcNow.Ticks, I notice that the value will jump a remarkable amount once every hour or so. Look closely at the following sample data: 1:52:14.312 PM - 633614215343125000 1:52:14.359 PM - 633614215343593750 1:52:14.421 PM - 633614215344218750 1:52:14.468 PM - 633...

.NET Minimize to Tray AND Minimize required resources

I have a WinForms application (I'm using VB) that can be minimized to the system tray. I used the "hackish" methods described in multiple posts utilizing a NotifyIcon and playing with the Form_Resize event. This all works fine aesthetically, but the resources and memory used are unaffected. I want to be able to minimize resources when ...

Checking for equivalent shared folders in .net

Is there a way, within the .net framework, to check to see if two different shared folders are actually pointing to the same physical directory? Do directories in Windows have some sort of unique identifier? Google-fu is failing me. (I mean, aside from writing a temp file to one and seeing if it appears in the other) Edit: I think I'...

Change Keyboard Layout for Other Process

I'm writing a program in C# that runs in the background and allows users to use a htokey to switch keyboard layouts in the active window. (Windows only supports CTRL+SHIFT & ALT+SHIFT) I'm using RegisterHotKey to catch the hotkey, & it's working fine. The problem is that I can't find any API to change the keyboard layout for the focus...

What is the best algorithm for an overridden System.Object.GetHashCode?

In .NET System.Object.GetHashCode method is use in a lot of places throughout the .NET base class libraries. Especially when finding items in a collection fast or to determine equality. Is there a standard algorithm/ best practise on how to implement the GetHashCode override for my custom classes so I don't degrade performance? ...

Reading files in a .NET project

I have a C# .NET web project that I'm currently working on. What I'm trying to do is read some files that I dropped into a dir which is at the same level as fileReader.cs which is attempting to read them. On a normal desktop app the following would work: DirectoryInfo di = new DirectoryInfo(./myDir); However because it's a web proje...

Any tips for using Subversion with .net project files?

We just switched from TFS to SVN, and so far we're loving it. However, it did introduce a few new issues. One is the way project files (.vbproj specifically) are handled. The .vbproj file is of course always changing as files and references are changed, and if a few people are collaberating there will be conflicts. Oddly, in TFS we...

Reading Hibernate Properties from Web.config

The C# project I'm working on uses nHibernate and the connection string is in the web.config as a property of a Hibernate element. I need to read the connection string in the installer to get a connection manually without using Hibernate. I know I can use configManager.connectionStrings, but as the connection string is already defined ...

DirectoryEntry.NativeObject throws access denied for a user in Administrators group in windows 2008

I have a local user, which is member of Administrators local group. When I run this code: using System; using System.DirectoryServices; namespace nanttest { class Program { public static void Main(string[] args) { using(DirectoryEntry entry = new DirectoryEntry("IIS://localhost/W3SVC")) { object ab...