.net

Changing a Read Only attribute on a file

I can't seem to change the read only flag on a file. I've tried this on Vista and XP with the same result, so I don't think it's a UAC related issue. Nothing I've done seems to work though. See the sample below. Can someone tell me what I'm doing wrong? public bool UpdateResFile(string fileName, string language, string objectName, stri...

.Net WebBrowser Control encapsulating anything else but IE?

We're using SHDocVw.dll for providing a web browser control to some of our users that access our system through a gadget they install on their computers. Now, that control encapsulates IE. Anyone knows of ways to let the users choose what browser to encapsulate? EDIT - Clarifying: I'm interested in being able to encapsulate another brow...

T4 vs CodeDom vs Oslo

In an application scaffolding project on which I'm working, I'm trying to decide whether to use Oslo, T4 or CodeDom for generating code. Our goals are to keep dependencies to a minimum and drive code generation for a domain driven design from user stories. The first step will be to create the tests from the user stories, but we want the ...

Distributing applications where the configuration settings are encrypted using Entrerprise library

Hi All, I have a thought about this but could not come with a good solution. I have a windows application. I use enterprise library (3.1) Data Access Application Block. Now I use the DataProtectionConfigurationProvider to encrypt the connection strings. This application has to be deployed across multiple machines. I don't want the end...

C#/.NET: Blocking and waiting for an event

It sometimes want to block my thread while waiting for a event to occur. I usually do it something like this: private AutoResetEvent _autoResetEvent = new AutoResetEvent(false); private void OnEvent(object sender, EventArgs e){ _autoResetEvent.Set(); } // ... button.Click += OnEvent; try{ _autoResetEvent.WaitOne(); } finally{ b...

IP Routing

I have a WinForms application that our customer install locally and it is accessing our webservers through a leased/private network. All WS calls is getting routed properly when adressing our web server, but when the application is trying to access some other external resource (RSS) that is on the WWW - .Net/Windows is sending this reque...

How do I extract all {} tokens from a string using .Net's RegEx?

I need to extract tokens that are marked with curly brackets from a given string. I have tried using Expresso to construct something that will parse... ------------------------------------------------------------- "{Token1}asdasasd{Token2}asd asdacscadase dfb db {Token3}" ------------------------------------------------------------- ...

Control changes in windows form C#

I have a form with several components like textbox and combobox and I need to know when click in the out button if was any changes in the form. There are any way to do this? ...

Is there an equivalent to 'sscanf()' in .NET?

The .NET Framework gives us the Format method: string s = string.Format("This {0} very {1}.", "is", "funny"); // s is now: "This is very funny." I would like an "Unformat" function, something like: object[] params = string.Unformat("This {0} very {1}.", "This is very funny."); // params is now: ["is", "funny"] I know something simi...

When to use .NET BufferedStream class ?

The MSDN site states: A buffer is a block of bytes in memory used to cache data, thereby reducing the number of calls to the operating system. Buffers improve read and write performance. A buffer can be used for either reading or writing, but never both simultaneously. The Read and Write methods of BufferedStream auto...

Recommend a good ADO.NET book?

Any good books on ADO.NET out there? Please let me know. Thanks. ...

C# Read Line from Byte Array (Not Convert Byte Array to String)

I have a byte array that I am reading in from a NetworkStream. The first two bytes tell the length of the packet that follows and then the packet is read into a byte array of that length. The data in that I need to read from the NetworkStream/byte array has a few Strings, i.e. variable length data terminated by new line characters, and s...

Which data structure should I use? (.NET)

Here is the structure of the data my object will need to expose (the data is NOT really stored in XML, it was just the easiest way to illustrate the layout): <Department id="Accounting"> <Employee id="1234">Joe Jones</Employee> <Employee id="5678">Steve Smith</Employee> </Department> <Department id="Marketing"> <Employee id="3223"...

Interacting With Java Applet

Does anyone know if it is possible to interact with a java applet via .net? Edit: I was able to use the UI Automation framework to locate the java applet, and from there use OCR to read data and simulate mouse/keyboard input into the applet. ...

Contracts in C# 4.0

If I have a Vector3.Normalize() method that specifies a post condition where the resultant Vector3 is gonna have a length of 1, how would the compiler check for this at compile time (or before)? Does it just pass a random Vector3 variable to the method? ...

How to split a string while preserving line endings?

I have a block of text and I want to get its lines without losing the \r and \n at the end. Right now, I have the following (suboptimal code): string[] lines = tbIn.Text.Split('\n') .Select(t => t.Replace("\r", "\r\n")).ToArray(); So I'm wondering - is there a better way to do it? Accepted answer string[] lines ...

Initialize base class in .NET

How do I go about if I need to initialize an object's base with existing object? For example, in this scenario: public class A { public string field1; public string field2; } public class B : A { public string field3; public void Assign(A source) { this.base = source; // <-- will not work, what can I do here...

.NET - Unit Testing Your Code and State in Your Database

Assumptions: We use .NET coding against SQL Server 2005 I was just wondering how most people incorporate state into the Unit Tests that affect their database? I know when and where to use mocking, but when you want to move past that and actually do some database tests... what strategies do you use to setup and teardown your database? Do...

Free advanced dropdown list control (Windows Forms .Net)

I'm looking for a free advanced dropdown list control. Basically something that provides a dropdown list which can have icons, and multiple bits of text per entry (preferably one large bit of text and then a smaller bit of text underneath). Anyone know of such a control? I've had a look but can't seem to find one. If I can't find it I ...

Is there a DOS command for verifying what version of .NET is installed

I have set of scripts for doing scripted installs. You can use the scripts on any server 2008 machine. However, I need to check if .NET 3.5 has been installed (before the scripts run) using a dos batch file. Is that possible? I know I can check if a file in the C:\WINDOWS\Microsoft.NET\Framework\v3.5 exists, but it would be nice to...