.net

how to find a string pattern and print it from my text file using C#

i have a text file with string "abcdef" I want to search for the string "abc" in my test file ... and print the next two character for abc ..here it is "de". how i could accomplish ? which class and function? ...

Is it ok to call a service method in an other service method ? (WCF)

Sample code: public class Service1 { public int Service1() { .... } } public class Service2 { public int Service2() { ... var service1 = new Service1(); var count = service1.Service1(); ... } } Both classes and methods are exposed thru WCF. ...

WCF contracts - namespaces and SerializationExceptions

I am using a third party web service that offers the following calls and responses http://api.athirdparty.com/rest/foo?apikey=1234 <response> <foo>this is a foo</foo> </response> and http://api.athirdparty.com/rest/bar?apikey=1234 <response> <bar>this is a bar</bar> </response> This is the contract and supporting types I wrot...

Unable to cast object of type 'System.String' to type 'System.Web.Security.MembershipUser'

I'm trying to get a list of usernames and bind them to a DropDownList and I must be missing a trick because I can't seem to cast it to the correct type. The code is below and the title is the error message I'm recieving. EDIT - QUser inherits from MembershipUser UserRepository userRepository = new UserRepository(); // retrieve custom u...

How to continue from where I have been searching to find the index?

How to continue from where I have been searching to find the index? I am searching in a file to find the index of a character; then I have to continue from there to find the index of the next character. For example : string is " habcdefghij" int index = message.IndexOf("c"); Label2.Text = index.ToString(); labe...

What is the difference between StreamWriter.Flush() and StreamWriter.Close()?

What is the difference in functionality between StreamWriter.Flush() and StreamWriter.Close()? When my data wasn't being written correctly to a file, I added both Flush() and Close() to the end of my code. However, I realized that adding either Flush() or Close() allowed the data to be written correctly. I wasn't able to pick up on ex...

Enumerating Network Sessions

Hi, I wanted to pull data about the connected network users from the Computer Management -> Shared Folders -> Sessions tab into my c# application. Can anybody guide me on what namespaces have to be used along with some sample code to import username and ip address from Computer Management -> Shared Folders -> Sessions tab? Regards ...

Why can you call BeginInvoke more than once on the same delegate instance?

I thought that calling BeginInvoke more than once on the same delegate instance would cause problems, but I tried it out and it works. Why is that? Is the IAsyncResult object returned with each BeginInvoke called unique instead of each instance of the delegate? In other words, do I only need one instance of the delegate to spawn multip...

friendly classes in c#

hey folks! actually i refactor some portion of code. what i want to do is to initialize an object "Task" with an object "TaskArgument". let s say "TaskArgument" is abstract and "Task" implements a method "OnEnterTask(TaskArgument args)" and is sealed (for some special behavior of the existing system, which is out of scope). old code: ...

.NET webservice datetime.now - time zone

I need to return server time from a webservice. I've got the following code: <WebMethod()> _ Public Function GetDate() As DateTime Return DateTime.Now End Function The code always returns time based on timezone of the connected client (if I change the time zone, the webservice returns updated time, instead of local server tim...

Multithreading recommendation based on program description

I would like to describe some specifics of my program and get feedback on what the best multithreading model to use would be most applicable. I've spent a lot of time now reading on ThreadPool, Threads, Producer/Consumer, etc. and have yet to come to solid conclusions. I have a list of files (all the same format) but with different con...

Display new image on web page

Hello, I'm uploading images to a folder and I want to display each new image on a web page every time it is saved in the folder. I can display the initial image, which is already in the folder, and I can also detect when a new image is saved into the folder but I don't know how to display the new images. I'm new to web development. C...

NHIbernate Newbie: Can someone please explain why NHibernate attempts to execute a database update during CreateQuery execution

Basically, I wish to fetch a filtered set of objects from the database (Oracle 9.2) based on the id property of the object PsalertsEvent. The code being executed is: Public Overloads Function GetAll(ByVal laterThan As Long, ByVal filteredPsalertsEvents As IList) As IList Implements IPsalertsEventRepo.GetAll 'Get all psalert...

Visual Studio 2008: How to redirect Trace, Debug and Console output to the Output window?

I have noticed recently that the Visual Studio "Output window" stopped writing out my Debug.WriteLine messages in my WinForms application. It does neither output the Trace.WriteLine messages. I have also used DebugView while running this application and it shows nothing. I am sure it worked in some VS projects some time ago - the output...

Server Error in '/' Application.

I am getting the following error; how to resolve this? Server Error in '/' Application. Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS1061: 'Sy...

Is .NET's FileInfo.Length property lazy?

The following code generates a FileNotFoundException (using .NET 2.0): using System; using System.Collections.Generic; using System.Text; using System.IO; namespace LazyFileInfoTest { class Program { static void Main(string[] args) { File.WriteAllText("Test.txt", "Hello World!"); Directo...

C# - Get a list of files excluding those that are hidden

Directory.GetFiles() returns all files, even those that are marked as hidden. Is there a way to get a list of files that excludes hidden files? ...

How to properly develop and deploy features for existing asp.net applications on IIS

My question actually consists of multiple questions. I'm frequently reading about companies who deploy a small subset of features for a select amount of customers using the live "database". Ruby on Rails and its ecosystem have deployment tools and database migrations to deploy or rollback such features in a live production or staging env...

Understanding PowerShell Hosting

I've done some work hosting PowerShell and have done a lot of reading but I am seeing strange behavior and it makes me wonder if I do not understand the host like I thought I did. I am creating a Runspace with RunspaceFactory: var runSpace = RunspaceFactory.CreateRunspace() I'm utilizing the same runspace throughout the execution o...

.net multithreading study material

Can any one share some study material for multithreading on .net? EDIT: I don't want to learn too much details ...