113
votes
23answers
65k views

How to detect Windows 64-bit platform with .NET?

In a .NET 2.0 C# application I use the following code to detect the operating system platform: string os_platform = System.Environment.OSVersion.Platform.ToString(); This returns "Win32NT". The ...
106
votes
13answers
31k views

How can I update the current line in a C# Windows Console App?

When building a Windows Console App in C#, is it possible to write to the console without having to extend a current line or go to a new line? For example, if I want to show a percentage representing ...
82
votes
3answers
62k views

How to get a path to the desktop for current user in C#?

How do I get a path to the desktop for current user in C#? The only thing I could find was the VB.NET-only class SpecialDirectories, which has this property: ...
65
votes
19answers
47k views

How check if given string is legal (allowed) file name under Windows?

I want to include batch file rename functionality in my application. User can type destination filename pattern and (after replacing some wildcards in pattern) I need to check if it's going to be ...
58
votes
15answers
24k views

Memcached on Windows (x64)

Does anyone know IF, WHEN or HOW I can get Memcached running on a Windows 64bit environment? I'm setting up a new hosting solution and would much prefer to run a 64bit OS, and since it's an ASP.Net ...
54
votes
14answers
71k views

How to shutdown the computer from C#

What's the best way to shutdown the computer from a C# program? I've found a few methods that work - I'll post them below - but none of them are very elegant. I'm looking for something that's simpler ...
48
votes
13answers
3k views

Is the Windows dev environment worth the cost? [closed]

I recently made the move from Linux development to Windows development. And as much of a Linux enthusiast that I am, I have to say - C# is a beautiful language, Visual Studio is terrific, and now ...
46
votes
7answers
36k views

Accessing a Shared File (UNC) From a Remote, Non-Trusted Domain With Credentials

We've run into an interesting situation that needs solving, and my searches have turned up nill. I therefore appeal to the SO community for help. The issue is this: we have a need to programmatically ...
41
votes
5answers
29k views

How do I get the title of the current active window using c#?

I'd like to know how to grab the Window title of the current active window (i.e. the one that has focus) using C#.
39
votes
9answers
16k views

Using C#, how does one figure out what process locked a file?

In Windows, how do I determine (using C#) what process locked a file? Third-party tools are helpful, but not what I'm looking for.
35
votes
10answers
9k views

.NET WPF Remember window size between sessions

Basically when user resizes my application's window I want application to be same size when application is re-opened again. At first I though of handling SizeChanged event and save Height and Width, ...
35
votes
6answers
6k views

How to get the word under the cursor in Windows?

I want to create a application which gets the word under the cursor (not only for text fields), but I can't find how to do that. Using OCR is pretty hard. The only thing I've seen working is the ...
34
votes
5answers
36k views

Elevating process privilege programatically?

I'm trying to install a service using InstallUtil.exe but invoked through Process.Start. Here's the code: ProcessStartInfo startInfo = new ProcessStartInfo (m_strInstallUtil, strExePath); ...
34
votes
3answers
31k views

How to validate domain credentials?

i want to validate a set of credentials against the domain controller. e.g.: Username: STACKOVERFLOW\joel Password: splotchy Method 1. Query Active Directory with Impersonation A lot of people ...
32
votes
8answers
14k views

How do I spawn threads on different CPU cores?

Let's say I had a program in C# that did something computationally expensive, like encoding a list of WAV files into MP3's. Ordinarily I would encode the files one at a time, but let's say I wanted ...

1 2 3 4 5 392
15 30 50 per page