|
It would be better to hash the key before sending it, otherwise the keys could be stolen, and you don't really care about the key anyway - you're just using it to see whether it's "still the same key" which could also be done with hashes.
|
|
|
|
|
|
I want to create a c# winform application that creates & stores a list of tasks including date and status info. What are the options for storing my tasks. i read a little about serialisation and was considering that, is that a good idea ? What are the alternatives?
This is my first solo mini project aside from exercises in books, I would appreciate any help at all i'm looking for ideas and things to read up on mainly, all suggestions gratefully received.
|
|
|
|
|
SQL Server -- or any database.
Eventually you'll want to learn about reading and writing text and XML files so those are possibilities, but not as good.
|
|
|
|
|
Serialisation allows you to create a list of objects, then store that as a binary file, and restore it from there. It may be a good choice in this case, as it doesn't involve requiring a database, learning SQL, etc.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Serialization is the easiest option by far. It's built into .NET, and is almost automatic.
But if the format of what you're saving changes, it becomes way more complex to read data you've stored in the old format.
Another disadvantage of serialization is that is becomes very bloated, taking up many times as much space in the serialized XML files as the original data.
Another serialization disadvantage is that it's sometimes buggy and unreliable. Some things require complex workarounds (which you can find on the web), some things can't be serialized, and (surprisingly) some things can only be serialized some of the time.
Do some simple tests to see if it's adequate for what you want to store/retrieve.
|
|
|
|
|
Thanks for all your help, i think i will have a look at SQL & MSDE , i have a little experience with it . Serialisation sounds like it could get complicated quickly. Really impressed with the speed and detail in your replies guys i will certainly be using this site as a resource in future.
Cheers
|
|
|
|
|
Hi guys.
I'm using LINQ to modify a database.
I want to take a back up from the database.
Could you please guide me , how I can do it with LINQ ?
|
|
|
|
|
I think this would receive a better response if posted to the LINQ or Database forums.
|
|
|
|
|
Hey friends. I have been doing C# for over a year just with 3 months learning,with my effort and with the help of this forum. I knew the basics of C#. Specially windows From programmint with C#. But now I wanted to move to the next step.i.e I wanted to be as best as possible with Socket Programming,Web based programming with C# and so on . and know I wanted to buy a nice advanced C# book which will help me just for this start. I searched google and I got books but I couldnt see thier outline. So can you give me the books you know that are best for this purpose,if I can see the outline please . I hope every body will cooperate with that .
Thanks a lot.
|
|
|
|
|
You should read CLR via C#[^] by Jeffrey Richter.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Thank you for your responce ............ But i cant get outlines about Socket Programming from the table of contents.
So can you point me that one.Thank you
|
|
|
|
|
I found this article[^] here on Code Project. Not too far away really!
|
|
|
|
|
thank you man .... I will work on it. But to brief my idea i wasnt just to search a code (even if it helps) ... to have a detailed idea about Socket Programming and others I wish i had a nice book on that. Thank you.
|
|
|
|
|
CoderForEver wrote: I wish i had a nice book on that.
Sure, but sometimes you will find that the guy who wrote the article will know of one; you can always try to contact him via his article. Also just try a Google search on the subject and read some of the book reviews.
|
|
|
|
|
thank you for your responce
|
|
|
|
|
Hello all,
As you may know, in C# 3.0 and later we can add this kind of syntax to a class:
public class CMyClass
{
public int MyIntValue { get; set; }
}
The "get; set;" provides what MSDN documentation refers to as a "trivial" property. That is, there's no extra logic that needs to be applied to either the get or set part of the property. The compiler picks up on this syntax and auto-generates the underlying class member.
My question is: WHY IS THIS USEFUL??? If you have a property that has unrestricted get and set access, how is that any different than just declaring a public class member? Why do I need to waste the extra 13 keystrokes to type:
public int MyIntValue { get; set; }
instead of just:
public int MyIntValue;
To me this seems like an absolutely ridiculous syntax feature. Does anyone have any great insight into this?
|
|
|
|
|
Nothing, so go ahead and make the public field and enjoy the backward compatibility.
But! If you want the setter to have different (more-restricted) access than the getter, use an automatic property.
public int MyIntValue { get; protected set; }
Using the automatic property to begin with makes changing your mind later less problematic.
|
|
|
|
|
Now that makes a heck of a lot more sense. I didn't know split access is allowed like that. Thanks.
|
|
|
|
|
In addition to the reasons given in the response from PIEBALDconsult, if you are following the coding style guidelines (and I guess that you aren't ) you could also run into problems if you later need to change the access or the setting methods. Even if you do not follow the guidelines, the same circumstances could trip you up, requiring a great deal of retyping of references to the member, because there are often circumstances where accessing the member via the changed accessor could give side effects, where accessing the member directly wouldn't.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Inherently, the use of properties makes it a lot easier to serialize your class than if you use fields - not so ridiculous after all.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Ah, serialization. 99% of what I do is SQL Server-driven web applications. I can't remember the last time I needed serialization.
So apparently the "trivial property" has its uses, just not in my small little world 
|
|
|
|
|
I thought serialization was only useful for that Web crap, which is why I don't use serialization either.
|
|
|
|
|
Get/set make it easier to change how access to the property is handled, WITHOUT having to change your code every place the property is referenced.
For example, you could make the property (in effect) virtual, calculating it only if/when it's needed. Or you could easily add pre/post-processing to property accesses.
Another benefit is it gives you a location to set a breakpoint when debugging, so you can see WHERE accesses to this property are coming from.
|
|
|
|
|
Hi everyone.
I have a coded a Proxy Server like code that works really fine for me!
But there is an stupid problem!
When I begin surfing the internet through my program (using the proxy setting in firefox) at the beginning, the CPU usage is normal with some times raising up to 2 and then back to 0 again, but as soon as I open 2 or 3 pages in firefox, specially the page with flv videos, the CPU usage raises up to 99 percent!
Here is my TCP process code:
<br />
private void ClientConnectionHandler(object client)<br />
{ <br />
TcpClient tcpClient = null;<br />
<br />
NetworkStream networkStream = null;<br />
<br />
TcpClient remoteTcpClient = null;<br />
<br />
NetworkStream remoteNetworkStream = null;<br />
<br />
try<br />
{<br />
tcpClient = (TcpClient)client;<br />
<br />
const int bufferSize = 1024;<br />
<br />
byte[] buffer = new byte[bufferSize];<br />
<br />
tcpClient.ReceiveBufferSize = bufferSize;<br />
<br />
tcpClient.SendBufferSize = bufferSize;<br />
<br />
networkStream = tcpClient.GetStream();<br />
<br />
int bytesRead = networkStream.Read(buffer, 0, bufferSize);<br />
<br />
string request = Encoding.ASCII.GetString(buffer, 0, bytesRead);<br />
<br />
string host = "";<br />
<br />
string[] headers = request.Split(new string[] { "\r\n" }, StringSplitOptions.None);<br />
<br />
foreach (string header in headers)<br />
{<br />
if (header.ToLower().Replace(" ", "").Contains("host:"))<br />
{<br />
host = header.Replace(" ", "").Split(':')[1];<br />
}<br />
}<br />
<br />
IPAddress[] hostAddresses = Dns.GetHostAddresses(host);<br />
<br />
remoteTcpClient = new TcpClient<br />
{<br />
ReceiveBufferSize = bufferSize,<br />
SendBufferSize = bufferSize<br />
};<br />
<br />
remoteTcpClient.Connect(hostAddresses[0].ToString(), 80);<br />
<br />
remoteNetworkStream = remoteTcpClient.GetStream();<br />
<br />
remoteNetworkStream.Write(buffer, 0, bytesRead);<br />
<br />
bool eof =<br />
request.Contains("\r\n");<br />
<br />
while (!eof)<br />
{<br />
bytesRead = networkStream.Read(buffer, 0, bufferSize);<br />
<br />
remoteNetworkStream.Write(buffer, 0, bytesRead);<br />
<br />
eof =<br />
Encoding.ASCII.GetString(buffer, 0, bytesRead).Contains("\r\n");<br />
}<br />
<br />
bytesRead = remoteNetworkStream.Read(buffer, 0, bufferSize);<br />
<br />
int received = bytesRead;<br />
<br />
networkStream.Write(buffer, 0, bytesRead);<br />
<br />
string response = Encoding.ASCII.GetString(buffer, 0, bytesRead);<br />
<br />
int contentLength = 0;<br />
<br />
headers = response.Split(new string[] { "\r\n" }, StringSplitOptions.None);<br />
<br />
foreach (string header in headers)<br />
{<br />
if (header.ToLower().Replace(" ", "").Contains("content-length:"))<br />
{<br />
contentLength = int.Parse(header.Replace(" ", "").Split(':')[1]);<br />
}<br />
}<br />
<br />
int headerLength = response.IndexOf("\r\n\r\n") + 4;<br />
<br />
int totalLength = headerLength + contentLength;<br />
<br />
eof = (received == totalLength);<br />
<br />
while (!eof)<br />
{<br />
bytesRead = remoteNetworkStream.Read(buffer, 0, bufferSize);<br />
<br />
BytesRecieve += bytesRead;<br />
<br />
received += bytesRead;<br />
<br />
networkStream.Write(buffer, 0, bytesRead);<br />
<br />
eof =<br />
(received == totalLength);<br />
}<br />
}<br />
catch (Exception e)<br />
{<br />
Console.WriteLine(e.Message + "\r\n\r\n");<br />
}<br />
finally<br />
{<br />
if (tcpClient != null) tcpClient.Close();<br />
<br />
if (networkStream != null)<br />
{<br />
networkStream.Close();<br />
<br />
networkStream.Dispose();<br />
}<br />
<br />
if (remoteTcpClient != null) remoteTcpClient.Close();<br />
<br />
if (remoteNetworkStream != null)<br />
{<br />
remoteNetworkStream.Close();<br />
<br />
remoteNetworkStream.Dispose();<br />
}<br />
}<br />
<br />
Thread.CurrentThread.Abort();<br />
}<br />
I start the TcpListener usign this method:
<br />
private void StartServer()<br />
{<br />
var tcpListener = new TcpListener("127.0.0.1",777);<br />
<br />
tcpListener.Start();<br />
<br />
ThreadPool.SetMaxThreads(5, 5);<br />
<br />
while (AcceptConnection)<br />
{<br />
TcpClient tcpClient = tcpListener.AcceptTcpClient();<br />
<br />
ThreadPool.QueueUserWorkItem(ClientConnectionHandler, tcpClient);<br />
}<br />
}<br />
And also, I used these in a console program.
Does anyone know the problem please?
Sojaner!
|
|
|
|