|
BinaryReader and BinaryWriter are probably the classes you are looking for.
Regards,
Rob Philpott.
|
|
|
|
|
Hi
Thanx for the reply. I know BinaryReader and BinaryWriter classes are used for reading and writing but i am unable to use it properly can u give me some sort of code(example) for both so that it will help me ahead?
thanx again
Nitin
|
|
|
|
|
What sort of data is it you are writing? Are you trying to write it in a specific format? Is it binary serialisation you are after or more just straight streaming of data?
Regards,
Rob Philpott.
|
|
|
|
|
What does the binary data represent? An image, text or sth. else?
Because I don't know what you try to achieve, I would say you have to use a BinaryWriter/BinaryReader.
Regards
Sebastian
|
|
|
|
|
Hi thanx for your reply. Binary data presents text and some data like which contain numbers. i know that Binarywriter/BinaryReader class is used for that...but can u give me some sort of code for both reading and writing, so that it will help me ahead?
Thanx again
Nitin
|
|
|
|
|
|
BinaryReader/BinaryWriter as has already been suggested.
If you are trying to save your own internal objects in a proprietary format also take a look at BinarySerializer
|
|
|
|
|
File.ReadAllBytes and File.WriteAllBytes
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hi,
I'm trying to build a self updating application for Mobile use.
I'd like to use the AppDomain.ShadowCopy feature so that my code will be loaded without the CLR locking the assembly. This way the code is able to update itself.
My only problem is that the ShadowCopy is being excluded from the Compact version of the .NET...
Any idea for a substitute, or any other way I can self-update an assembly?
tnx
Roy
|
|
|
|
|
i m new to game dev and now developing a small 2d scrolling game in VC# 2005 using XNA framework. i completed the player movements, and some player controls(like shooting).
now i donno how to write code for a mission. not even a basic idea of how to start with it. (for eg. mission is to shoot X ppl in some Y time). shud i hav to hard code in the update method or write mission details in a separate data file and read from it, and check for condition...
pls pls pls some one help me on this...
|
|
|
|
|
Most people create a format to define missions, and then write a program with which they can create as many missions as they like, just by creating new data files.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
thanks for ur explanation. but i still need some sample or tutorial to understand the concept... cud u give me some link to such kind of tutorial... i hav searched in google for about 15 minutes and havnt found any...
|
|
|
|
|
How it works, is up to you. I'm not going to write a game to show you. You could look to see if the XNA framework has any samples you can look at.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
|
Sorry but if i understand your question you want to store how many things you need to shoot and how long to do in?
well just use some variables, get from a file or something. simple file with level, target, time would do, i.e.
1-10-60
2-15-55
3-20-50
4-25-45
etc.
then for each level you load your target and time
My opinion is... If someone has already posted an answer, dont post the SAME answer
|
|
|
|
|
|
|
Hi expert ,
this is login code with Mysql Connectivity .it is not working.
no error is showing
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 MySql.Data.MySqlClient;
namespace ExampleOne
{
public partial class login : Form
{
public login()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void btnlogin_Click(object sender, EventArgs e)
{
string g_login = this.tbUsername.Text;
string g_password = this.tbpassword.Text;
string MyConString = "server=localhost;database=password;uid=root;password=asd";
MySqlConnection connection = new MySqlConnection(MyConString);
string Strsql = "select * from tablogin where userid = ' " + g_login + " 'AND password=' " + g_password + " ' ";
MySqlCommand command = new MySqlCommand(Strsql, connection);
MySqlDataReader Reader;
try
{
connection.Open();
Reader = command.ExecuteReader();
while (Reader.Read())
{
string auser;
string apwd;
auser = (Reader[g_login].ToString());
apwd = (Reader[g_password].ToString());
if (auser == g_login && apwd == g_password)
{
MessageBox.Show("INCORRECT USER/PASS!");
}
else
{
MessageBox.Show("YOU ARE LOGGED IN!");
}
}
connection.Close();
}
catch (Exception ex)
{
Console.WriteLine("Error Conecting to database", "window information" + ex.Message.ToString(),
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}
|
|
|
|
|
Your code is really, really crappy. I can erase your database any time I like. Apart from that, hard to say, given that you don't tell us what code executes, what you see, what happens, etc. Do you know how to use the debugger ? Any execution path should show a message box, so more detail than 'it's not working' should be easy to offer, even if you don't know how to debug code.
Also, the right way to check a login is to do a select count(*), not to get the username and password returned.
Oh, I see the issue.
ashish1nov2008 wrote: while (Reader.Read())
So, if nothing is returned, you won't see anything. Duh.
ashish1nov2008 wrote: else
{
MessageBox.Show("YOU ARE LOGGED IN!");
}
This can never execute, by definition.
Look at your SQL, make sure what you're typing in is correct ( for example, is there a trailing space in the DB and not in your text ? Can you think of ways to make that not matter ?
I think you need to read a basic C# book and start again.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Ooops SQL Injection
string Strsql = "select * from tablogin where userid = ' " + g_login + " 'AND password=' " + g_password + " ' ";
This is How you Should do it
First you have to Create a Storedprocure that counts the Records that match the username and password,
Create Procedure prclogin_check
(
@User_name varchar(20),
@U_Password varchar(23),
@Results int Output
)
IF EXISTS (Select * from User_Table
where User_name =@User_name and U_Password = @U_Password)
Set @Results =1
And after you are done with this , you have to do the Following in your C# Code
using System.Data.SqlClient;
String strcon = "User id = sa;Password= topman;Server=myServer;Database=MyDB";
SqlConnection con = new SqlConnection(strcon);
SqlCommand cmdselect = new SqlCommand();
cmdselect.CommandTimeout = 0;
cmdselect.CommandType = CommandType.StoredProcedure;
cmdselect.Connection = con;
cmdselect.CommandText = "prclogin_check";
cmdselect.Parameters.Add("@Results",SqlDbType.Int,4);
cmdselect.Parameters["@Results"].Direction = ParameterDirection.Output;
int Res;
try
{
con.Open();
cmdselect.ExecuteNonQuery();
Res = (int)cmdselect.Parameters["@Results"].Value;
con.Close();
}
catch (SqlException e)
{
MessageBox.Show(e.Message);
}using System.Data.SqlClient;
String strcon = "User id = sa;Password= topman;Server=myServer;Database=MyDB";
SqlConnection con = new SqlConnection(strcon);
SqlCommand cmdselect = new SqlCommand();
cmdselect.CommandTimeout = 0;
cmdselect.CommandType = CommandType.StoredProcedure;
cmdselect.Connection = con;
cmdselect.CommandText = "prclogin_check";
cmdselect.Parameters.Add("@Results",SqlDbType.Int,4);
cmdselect.Parameters["@Results"].Direction = ParameterDirection.Output;
int Res;
try
{
con.Open();
cmdselect.ExecuteNonQuery();
Res = (int)cmdselect.Parameters["@Results"].Value;
con.Close();
}
catch (SqlException e)
{
MessageBox.Show(e.Message);
}
And in your Business logic or in your Form you can create a Function that will test if the Count of Records is greater than 0,if its less than that , then its invalid login
Hope this Helps
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswam@its.co.za
|
|
|
|
|
hi, i looked up googles and everywhere.. but i couldn't solve the problem
this is my codes.
since i searched the gooles, lots of people say if you have "GetResponse() hang" it's because you didn't close the Response. but this cann't be my situation. Because, in my case, a timer has to run every 5 seconds so i can't do
" Response.close()". does anybody have any ideas??
[STAThread]
public static void Main(string [] args)
{
Application.Run(new HealthMon());
}
private void HealthMon_Load(object sender, System.EventArgs e)
{
this.CheckTimer.Interval = 5000;
this.CheckTimer.Start();
}
private void CheckTimer_Tick(object sender, System.EventArgs e)
{
System.Net.WebRequest request = null;
System.Net.HttpWebResponse response = null;
try
{
request = System.Net.WebRequest.Create("http://url.....");
response = (System.Net.HttpWebResponse)request.GetResponse();
GlobalProxySelection.Select = WebProxy.GetDefaultProxy();
if(response.StatusCode != HttpStatusCode.OK)
{
MessageBox.show("error");
}
else
{
MessageBox.show("success");
}
}
catch( Exception ex )
{
MessageBox.show("error");
}
}
|
|
|
|
|
Chances are if GetResponse() hangs, you have not recieved a response. Try putting in some different urls and see what happens. Also, have you configured your proxy correctly?
Regards,
Rob Philpott.
|
|
|
|
|
I have tried diffrent urls.. like localhost, and the other PC that is right next to me..
and I don't have proxy settings..
they all hangs... -_-
|
|
|
|
|
Don't know then. I've tried your code slightly modified (below) and it works fine. Suspicion turns to the timer. If you call this just once from Main rather than repeatedly, does it work?
public static void Main(string[] args)
{
System.Net.WebRequest request = null;
System.Net.HttpWebResponse response = null;
request = System.Net.WebRequest.Create("http://news.bbc.co.uk");
WebProxy p = new WebProxy("...our proxy", true);
p.UseDefaultCredentials = true;
request.Proxy = p;
response = (System.Net.HttpWebResponse)request.GetResponse();
}
Regards,
Rob Philpott.
|
|
|
|
|
yes! it only works for 2times.
the third time... hangs.. -_-
sometimes it goes more then two times, but the result is the same eventually..
|
|
|
|