using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net.Sockets; using System.Net; using System.Threading; namespace ServerSocketApp
Friday, February 10, 2012
How to Implement Threaded Server Socket Application
Saturday, February 4, 2012
Arrays in .NET Webservices
Web Service
Copy the URL of the WSDL
ex : http://localhost:4886/Service1.asmx?WSDL
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public int[] sort(int[] arr)
{
Array.Sort(arr);
return arr;
}
}
Then run the service.Copy the URL of the WSDL
ex : http://localhost:4886/Service1.asmx?WSDL
Labels:
Array,
C#.net,
Web Services
Reading Text from Files (C#.net)
private void button2_Click(object sender, EventArgs e)
{
try
{
string buffer;
StringBuilder stb = new StringBuilder();
StreamReader strmRdr = File.OpenText("c:\\testfile.txt");
while ((buffer = strmRdr.ReadLine()) != null)
{
stb.Append(buffer);
stb.Append(Environment.NewLine);
Labels:
C#.net,
StreamReader,
StringBuilder
Writing Text to files( C#.net )
private void button1_Click(object sender, EventArgs e)
{
try
{
FileStream fileStrm = File.Open("c:\\testfile.txt", FileMode.OpenOrCreate);
StreamWriter writer = new StreamWriter(fileStrm);
writer.WriteLine("First Line");
for (int i = 2; i < 100; i++)
{
writer.WriteLine("This is line {0}", i);
Labels:
C#.net,
FileStream,
StreamWriter,
TextFiles
Friday, February 3, 2012
Using DataGridView to Show Data in a table
Selecting multiple files and show their information on a DataGridView
public partial class Form1 : Form
{
private String[] selectedFiles;
public Form1()
{
InitializeComponent();
}
Labels:
C#.net,
Data,
DataGridView,
table
Using FileOpen Dialog
private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.Title = "Open a file to process";
//selectable file types
openFileDialog1.Filter = "Portable Document Format (*.pdf)|*.pdf|Text Documents(*.txt)|*.txt";
openFileDialog1.InitialDirectory = "c:\";
DialogResult respo= openFileDialog1.ShowDialog();
if (respo == DialogResult.OK)
{
textBox1.Text = openFileDialog1.FileName;
}
else
{
textBox1.Text = "No selected file!";
}
}
Labels:
C#.net,
FileOpenDialog,
Filter
Thursday, February 2, 2012
Progressbar Update In C#.net
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace ThreaddedApp
{
public partial class Form1 : Form
{
delegate void progressbarrunnerDelegate();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.Invoke(new progressbarrunnerDelegate(progressbarrunner));
}
private void progressbarrunner()
{
for (int i = 0; i < 100; i++)
{
Thread.Sleep(50);
this.progressBar1.Value = i;
Application.DoEvents();
}
}
}
}
Labels:
C#.net,
Delegates,
Progressbar,
Threads
Subscribe to:
Comments (Atom)