|
I'm trying to read the size and then get to the bits of any instance of data so I can teach it to a neural network. That way I can not only teach it strings, but also pictures for facial recognition, or other things, like maybe voice, or I can use it for error correction. I'm sure someone else has done it but I'm trying to learn C# and this is my project. If no one else has, I'll likely make it my first submission on here for others to see.
I've seen "marshall" in class roots on help pages but I don't know what that is.
|
|
|
|
|
|
Looks promising at a glance. I've been looking into just what marshaling is about and it's starting to gel, and this will help, thanks. Looking at the Marshal class seems to be just what I'm looking for, accessing the raw data.
|
|
|
|
|
Hello everybody, I tryed to make a software that check for updates:
Client: Login ( username , password ) , Receive update list , request updating files , get files , execute another process.
Server: Receive login , login on data-base if possible , send update list if logged , send requested files , logout.
Everythings are done, if I run CLIENT and SERVER on local computer, everythings works fine, but if I run SERVER on my computer, and CLIENT in another computer, the UPDATE doesnt work fine.
What happens:
Server can send any Text file good, in perfect state, but if I send binary files like JPG images, EXE, or any other things that arent TEXT FILES, it sends wrong BYTES, like if server is encoding all bytes to TEXT format...
===
CLIENT GET FILE VOID:
<br />
<br />
private void GetFile ( int FileNumber )<br />
{<br />
string FilePath = UpdateFileList[FileNumber];<br />
long FileSize = UpdateSizeList[FileNumber];<br />
<br />
long CurrentSize = 0;<br />
<br />
if ( FilePath.IndexOf("\\") > 0 )<br />
{<br />
string newDirectory = FilePath.Substring(0,FilePath.IndexOf("\\"));<br />
<br />
if ( !Directory.Exists(newDirectory) )<br />
Directory.CreateDirectory(newDirectory);<br />
}<br />
<br />
FileStream FS = new FileStream(FilePath,FileMode.Create,FileAccess.Write);<br />
<br />
while ( CurrentSize < FileSize )<br />
{<br />
try<br />
{<br />
this.Stats_Text.Text = "Downloading updatings ( " + (FileNumber+1) + " / " + UpdateFileList.Length + " )\n" + FilePath + " ( " + Convert.ToByte((Convert.ToDouble(CurrentSize)/Convert.ToDouble(FileSize))*100) + " % completed of " + (FileSize/1024) + " KBs )";<br />
long PacketSize = FileSize-CurrentSize;<br />
<br />
if ( PacketSize > 128 )<br />
PacketSize = 128;<br />
<br />
byte[] Packet = new byte[PacketSize];<br />
<br />
NS.Read(Packet,0,Packet.Length);<br />
NS.Flush();<br />
<br />
FS.Write(Packet,0,Packet.Length);<br />
FS.Flush();<br />
<br />
CurrentSize += PacketSize;<br />
FS.Seek(CurrentSize,SeekOrigin.Begin);<br />
}<br />
<br />
catch<br />
{<br />
try { File.Delete(FilePath); }<br />
catch {}<br />
<br />
this.Stats_Text.Text = "The connection with the Server was lost";<br />
Disconnect();<br />
}<br />
}<br />
<br />
FS.Close();<br />
}<br />
<br />
===
SERVER SEND FILE VOID:
<br />
<br />
private void SendFile ( int FileNumber )<br />
{<br />
Console.Write("US - Sending updating file : " + (FileNumber+1) + " / " + Owner.UpdateFileList.Length + " [ " + ClientUserName + " ]\n");<br />
<br />
string FilePath = Owner.UpdateFileList[FileNumber];<br />
long FileSize = Owner.UpdateSizeList[FileNumber];<br />
<br />
long CurrentSize = 0;<br />
<br />
FileStream FS = new FileStream(FilePath,FileMode.Open,FileAccess.Read);<br />
BinaryReader BR = new BinaryReader(FS);<br />
<br />
while ( CurrentSize < FileSize )<br />
{<br />
try<br />
{<br />
long PacketSize = FileSize-CurrentSize;<br />
<br />
if ( PacketSize > 128 )<br />
PacketSize = 128;<br />
<br />
byte[] Packet = new byte[PacketSize];<br />
Packet = BR.ReadBytes(Convert.ToInt32(PacketSize));<br />
<br />
NS.Write(Packet,0,Packet.Length);<br />
NS.Flush();<br />
<br />
CurrentSize += PacketSize;<br />
}<br />
<br />
catch<br />
{<br />
Disconnect();<br />
}<br />
}<br />
<br />
BR.Close();<br />
FS.Close();<br />
}<br />
<br />
===
Can someone help me plz? whats wrong on my code.
Thank you!
|
|
|
|
|
You could get a program like Ethereal and watch the traffic and see which side is corrupting the data for a start. That will let you narrow down which side is causing the problems and give you more information.
Other than that, check your properties and make sure your options are set properly. I had to deal with serial communications and it kept on screwing up at a certain character for seemingly no reason. The fix was that I forgot to set some ancient option buried in documentation.
|
|
|
|
|
Hello my friend, thank you very much, I tryed to hex the 2 files, look what happens:
Real File:
$121C ... 3B 00 CE 8B BE FE ...
Downloaded File:
$121C ... 3B 00 00 00 00 00 .... CE 8B BE FE ...
Its like add '00 00 00 etc' in the mid of file.
I am verifying right now if the CLIENT BUFFER is bigger than the packet, I ll check whats going on.
Thank you for the help.
if you know whats wrong, tell me, thx!
|
|
|
|
|
Its working now, I had to modify my code:
Server:
<br />
...<br />
<br />
NS.Write(Packet,0,Packet.Length);<br />
NS.Flush();<br />
<br />
Thread.Sleep(5);<br />
CurrentSize += PacketSize;<br />
<br />
...<br />
Client:
<br />
...<br />
<br />
NS.Read(Packet,0,Packet.Length);<br />
NS.Flush();<br />
<br />
Thread.Sleep(5);<br />
CurrentSize += PacketSize;<br />
<br />
...<br />
How ever, maybe 5 MS wont be enough, maybe 5 MS will be more than enough...
Is there a METHOD to wait until the CLIENT receive all the packet?
like: NS.Wait();
Thank you.
-- modified at 11:31 Sunday 5th March, 2006
|
|
|
|
|
When I did serial communications, the hardest part was to efficiently handle the data which is what you're against, but that was in VC++ not C# but I'll take a shot in the dark.
According to the NetworkStream documentation (which I assume you are using), there's a property called DataAvailable. Why not poll that property, when it's true, read the data?
I don't know how you make sure you transmit all the bytes efficiently, but think about this:
on a client connection:
1. server -> open file, capture file length as a 64-bit (8-byte) unsigned integer
2. server -> transmit the 8-bytes, client expects the same 8 bytes
(at this point, the client knows how many bytes it'll receive)
3. client -> simply loop until the recv'd byte count matches what it's expecting
Loop these 3 steps for each file you want to send.
The most efficient communications code I've written is code that's very flexible but powerful. This includes making sure both sides are constantly at the same step in communication. In VC++, I used the timeout features of events inside of threads.
Good luck.
|
|
|
|
|
Thank you my friend, I ll think about it
I ll test this property called DataAvaible.
Bye and really thank you.
|
|
|
|
|
Hi,
I am planning to import dll files ( created in C# by myself ) from SQL. Is it possible at all ?
Developing for Windows C# 2005 Express (.net 2.0)
|
|
|
|
|
It could be possible...
If you store into the database the bytes that are contained by your dll, and at the querry time you create a dll file with the contents of you field into the database.
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|
|
Hi,
How can I interact with a SysTreeView in another application? I'm writing an automation application, and I need to access and iterate over the contents of a SysTreeView that belongs to another application. I also need to emulate mouse clicks on the tree view items.
I believe I need to do it by sending window messages to the control, but how do I do that with C# and .NET?
I'm using .NET 2.0 by the way.
thanks
/luddet
|
|
|
|
|
i need to open a very big image in my application then make some draw operation.
I need so to scrool it like photoshop does.
What is the easier way and no sources expensive?
|
|
|
|
|
Use a scrollable control like a panel forexample.
set AutoScroll property of the panel to true. Add a picturebox control onto your panel and set SizeMode to AutoSize. Do NOT set Dock property of picturebox to any value. Set location of your picturebox to 0,0 which places it to the topleft corner of the parent panel. That's all.
|
|
|
|
|
I was browsing the internet the other day and I ended up at a website that had a keylogger as one of its products. Anyhoo it said that it could make the program virtually invisible to users.
My question is: How would I make a program disappear from the process list under task manager?
|
|
|
|
|
I do not believe that this is possible, unless the program is a dll and is injected into a currently running program or the dll is injected into the OS. Through programming you would be able to write a program to see what processes use what dlls, but the task manager does not have this capability and would inadvertenly hide the injected program from view. Hence the reason why the program is so called "'virtually' invisible to users"
Regards,
1tg46
Check out 3D Game Development with Dark Basic Professional [^]programming.
|
|
|
|
|
How to import a value from listBox to textBox
vasildb@yahoo.com
Vasildb
|
|
|
|
|
Are you trying to take a selected item from a listbox and populate it into a textbox?
|
|
|
|
|
If that is the case then something like this is probably what you're looking for:
textBox1.Text = listBox1.Items[listBox1.SelectedIndex].ToString();
Where textBox1 and listBox1 can be substituted for the names of the respective controls in your program.
Hope this helps,
PJC
|
|
|
|
|
I recently developed my first full custom control. It is a is a simple tab control that mimics VS.NET 2005 look and functions. What I am trying to accomplish next is adding design time support. I have read tutorials and articles on this, but I am try to figure out how to add certain events to the control once it is added to a form. For eaxmple I want the developer to be able to switch tabs in design time. What has to be done in order to accomplish this? Thanks in advance.
CBN
|
|
|
|
|
You would have to implement a Control Designer. ParentControlDesigner if I am correct.
Here are basic steps:
1) Create an inherited class of a ParentControlDesigner, or the designer that is best suited for you. For the purpose of instruction the inherited Designer is called TabDesigner.
2) For the control (Tab Control in this case) you will add the Desinger attribute to the control class with reference to TabDesigner
3) In TabDesigner you will override the WndProc function so that you can get a handle on all events to the TabControl. You will add any code you will like to change tabs and handle click events by processing WM_MOUSEMOVE and WM_RBUTTONCLICK (may not be exact constant names, check with API-Viewer (google it))
4) To add any VS menu items to your control during designer-time you will override the Verb collection property. In the initialization of the TabDesigner you will create a new Verb Collection and return the new verb collection in the Verb property
4) Test your control with the new designer during Design-Time
I would go into more detail with this information and include information on VS smart tags, but that would take longer. If you have any questions just ask.
Regards,
1tg46
P.S. This sounds like a good article that I could write, so check within the next month at this site and I may have posted an article on this subject.
Check out 3D Game Development with Dark Basic Professional [^]programming.
|
|
|
|
|
Thanks for all your information ... I am playing with this I have not found any good example code ... I will be excitinly waiting for your article!
|
|
|
|
|
Now the only problem that I see in writing this type of article is: What type of control would be both useful and simple to create that could use these design time features? I would want a control that wasn't so significant that it would take away from the overall article about the design time features. Any Suggestions?
Regards,
1tg46
Check out 3D Game Development with Dark Basic Professional [^]programming.
|
|
|
|
|
|
Hello, I want to slide a panel like f.e. toolbox in Visual Studio.
It works fine...as long as there are no further controls on it,
then it gets interrupted quite often (I guess because it repaints the controls on it every time) while applying the slide effect which looks ugly...
I tried several things, but nothing worked...any ideas or
suggestions? thanks.
-- modified at 13:48 Saturday 4th March, 2006
|
|
|
|