Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

CONVERT IMAGE TO BYTE USING ASP.NET

Labels: ,

Namespaces :-

System.Drawing;

Coding :-

byte[] bytArray;
Bitmap bImg = new Bitmap(Server.MapPath(path));
ImageConverter imgCon = new ImageConverter();
bytArray = (byte[])imgCon.ConvertTo(bImg , typeof(byte[]));

SEARCH ALL FLOPPY,CD AND HARD DISK DRIVES

Labels:

//search all floppy,cd and hard disk drives available in our PC
//its varies from system to system


for(char Ch='A';Ch<='Z';Ch++) { string Dir = Ch + @":\"; if (Directory.Exists(Dir)) {
disksListBox.Items.Add( Ch+ @":" ); //Add into ListBox
}
}

COPY AND PASTE THE DATA USING CLIPBOARD

Labels:

//copy the data using Clipboard

Clipboard.SetDataObject(textBox1.SelectedText,true);

//paste the data using Clipboard

IDataObject iData = Clipboard.GetDataObject();

//Determine whether the data is in a format you can use.

if(iData.GetDataPresent(DataFormats.Text))
{
textBox1.SelectedText =(String)iData.GetData(DataFormats.Text); //display it in a text box.
}

GET THE USER NAME IN C# FOR NT AUTHENTICATION

Labels:

//Declare the Header File

using System.Security.Principal;
string a;

a=System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();

//Above Statement,opens us up to more than just the current user.

MessageBox.Show(a.ToString());

WRITE THE DATA INTO FILE

Labels:

using(StreamWriter sr=new StreamWriter("F:\\out.txt"))
{
sw.write("Have a nice day");
Response.write("saved");
}

READ THE DATA FROM FILE

Labels:

using(StreamReader sr=new StreamReader("h:\\appl.txt"))
{
while(sr.ReadLine()!=null)
{
string s;
s=sr.ReadLine();
ListBox1.Items.Add(s);
}
}