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
Monday, January 23, 2012
Using GET and POST methods in J2ME
Most of the mobile applications are not alone. They frequently communicate with web services or web applications to accomplish their tasks. Lets see how to make GET and POST requests to a server.
We can use HttpConnection class to make requests.
Lets see what are the basic steps.
We can use HttpConnection class to make requests.
Lets see what are the basic steps.
Labels:
Connector,
GET,
HTTP. HttpConnection,
InputStream,
J2ME. LWUIT,
OutputStream,
POST,
StringBuffer
Saturday, January 21, 2012
Python Note 8 (Python Utilities)
Summary
filenames = os.listdir(dir) -- list of filenames in that directory path (not including . and ..). The filenames are just the names in the directory, not their absolute paths.
addins
AppCompat
AppPatch
assembly
avastSS.scr
bfsvc.exe
filenames = os.listdir(dir) -- list of filenames in that directory path (not including . and ..). The filenames are just the names in the directory, not their absolute paths.
import os
dir="c:/"
files=os.listdir(dir)
for path in files:
print(path)
Output :addins
AppCompat
AppPatch
assembly
avastSS.scr
bfsvc.exe
Python Note 7 (the pickle module)
In python we can use serialization functionality using pickle module. it can save live instances of objects to files and retrieve object instances from pickled files.
Code:
Code:
import pickle
class Transaction :
def __init__(self,userName,trnsID,payment):
self.userName=userName
self.trnsID=trnsID
self.payment=payment
def __del__(self):
print("Destructed!")
def getPaymentValue(self):
return self.payment
def getUserName(self) :
return self.userName
#end of the class
Labels:
class,
dump,
file,
load,
object,
persistance,
pickle,
Python,
serialization
Subscribe to:
Comments (Atom)