|
Thanks for quick response,
Its not a predefined function, just I want to know the equivalent syntax thats it.
Thanks
|
|
|
|
|
byte[] CardType = new byte[2];
stu = MF_Request(DeviceAddr, 0, CardType);
Message("Request Card", stu);
string str = null;
if (stu == 0) {
str = string.Format(" ==> CardType(Hex): {0:x2}{1:x2}", CardType[0], CardType[1]);
}
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
(via C++ to C# Converter):
byte[] CardType = new byte[2];
stu = MF_Request(DeviceAddr, 0, CardType);
Message("Request Card", stu);
string str;
string code = new string(new char[100]);
if (stu == 0)
{
str = " ==> CardType(Hex): ";
code = string.Format("{0:X2}{1:X2}", CardType[0], CardType[1]);
str += code;
}
David Anton
http://www.tangiblesoftwaresolutions.com
C++ to C# Converter
C++ to VB Converter
C++ to Java Converter
VB & C# to Java Converter
Java to VB & C# Converter
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: convert VB, C#, or Java to C++/CLI
|
|
|
|
|
I got a lib file from http://69.10.233.10/KB/IP/pop3client.aspx[^], and i was hoping someone could hep me with a problem im having.
I normally use thunderbird, so all the tests i do, i compare with the results from thunderbird. When i try to retrieve a plain text mail with the code i downloaded (above), it works great. The problem occurs when i try to download a compressed file (GZip compression algorythm).
This works fine with thunderbird, but the code i downloaded seems to hack up the file. When i compared the results with a hex editor (EditpadPro), the difference in files is enormous, your src seems to change the chars around (eg first 7 hex from thunderbird: 02 00 00 00 FF FF 73, first 7 from your src: 41 67 41 41 41 50 2F), also when i download the file with thunderbird is's 98 bytes, and when i use code i downloaded, the file size is 138 bytes.
This tells me that the file is still ok on the SMTP server, it's just when it gets downloaded. So im assuming its a encoding problem (not 100% sure).
Iv tried this with .Net 2.0, and Mono 1.9.1.
Thanks in advance.
George.
|
|
|
|
|
GeorgeBerry wrote: The problem occurs when i try to download a compressed file (GZip compression algorythm).
So, did you decompress the file after you downloaded it?
|
|
|
|
|
When i try to decompress the files, it doesnt work, i get an exception coz the file isnt in its origional state.
|
|
|
|
|
GeorgeBerry wrote: i get an exception coz the file isnt in its origional state.
Can you paste the exception?
Have you tried downloading the file manually and added a .gz extension, and checked inside the compressed file with WinZip/WinRAR?
|
|
|
|
|
The compression algorythm i use doesnt play well with gzip, and other progs, it doesnt have all the wrapper classes, and checks that they use, so only a bare GZip decompression stream will be able to decompress it.
The thing is, that i need to be able to download it with the lib file (mentioned above).
Also if i download the entire email with thunderbird, the chars are exactly the same as the with the lib file, its only when i tell thunderbird to download that attachment, that it works properly. Dont know if this behaviour provides necessary info or not.
Thanks.
|
|
|
|
|
GeorgeBerry wrote: The compression algorythm i use doesnt play well with gzip
Which one are you using? Why not use the builtin stuff in .NET?
GeorgeBerry wrote: Also if i download the entire email with thunderbird, the chars are exactly the same as the with the lib file, its only when i tell thunderbird to download that attachment, that it works properly. Dont know if this behaviour provides necessary info or not.
You sure the attachment is not in BASE64 instead of being compressed? This would make sense in light of your observations.
|
|
|
|
|
I am using the System.IO.Compression class, but if you use this, you cant just pull the compressed data out from any ol' compression app.
well, as far as iv been told, base64, is the textual interpretation of a binary file, so in this case, it would seem that it is base64. However when i try to
byte[] TempArr = System.Convert.FromBase64String(DownloadedText);
I get the exception message "Invalid character found.".
Just a side not, i dont know that much about encodings, just a little. This is the first time iv had to create a POP3 client.
|
|
|
|
|
GeorgeBerry wrote: well, as far as iv been told, base64, is the textual interpretation of a binary file, so in this case, it would seem that it is base64. However when i try to
byte[] TempArr = System.Convert.FromBase64String(DownloadedText);
I get the exception message "Invalid character found.".
You are probably passing too much data (it expects only the attachment bit, the garbled text), but I think you are on the right path with Base64
|
|
|
|
|
When i try to convert:
This is a multi-part message in MIME format.
--------------060102020601080008090504
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
--------------060102020601080008090504
Content-Type: application/octet-stream;
name="sig.zpf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="sig.zpf"
AgAAAP//c0/NL0pPVXBKLSqq5ApJzUktKUpMTi1S0AgoqdRU8ClJ4XLNTczMUUgHq3MogavQ
S87Xq0oEabFS0DAwMtRUMDEy0TW3tDDgck7NAQoaWBjrmhqb6RqbGJhzAQA=
--------------060102020601080008090504--
i get the error "Invalid character found.", when i try to convert:
--------------060102020601080008090504
Content-Type: application/octet-stream;
name="sig.zpf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="sig.zpf"
AgAAAP//c0/NL0pPVXBKLSqq5ApJzUktKUpMTi1S0AgoqdRU8ClJ4XLNTczMUUgHq3MogavQ
S87Xq0oEabFS0DAwMtRUMDEy0TW3tDDgck7NAQoaWBjrmhqb6RqbGJhzAQA=
--------------060102020601080008090504--
i get "Invalid length.", and when i try to convert:
AgAAAP//c0/NL0pPVXBKLSqq5ApJzUktKUpMTi1S0AgoqdRU8ClJ4XLNTczMUUgHq3MogavQ
S87Xq0oEabFS0DAwMtRUMDEy0TW3tDDgck7NAQoaWBjrmhqb6RqbGJhzAQA=
i get the error "Invalid character found.".
Yeeh, iv tried all 3... i know "reaching for straws" right.
lol, i just cant think of anything else too try.
Thanks for the replies, definately getting closer too the solution.
|
|
|
|
|
Almost there!
This is the only bit you need to decode:
AgAAAP
S87Xq0oEabFS0DAwMtRUMDEy0TW3tDDgck7NAQoaWBjrmhqb6RqbGJhzAQA= I cant be sure, but it looks like it is always ending with a '='. You may have to remove the newline characters too.
Good luck
|
|
|
|
|
George. You can't try to decode the entire mime part as it's not encoded. You can only decode the data that is encoded with Base64, which is:
AgAAAP
S87Xq0oEabFS0DAwMtRUMDEy0TW3tDDgck7NAQoaWBjrmhqb6RqbGJhzAQA=
I could decode it fine.
When I run this:
string test = @"AgAAAP//c0/NL0pPVXBKLSqq5ApJzUktKUpMTi1S0AgoqdRU8ClJ4XLNTczMUUgHq3MogavQ
S87Xq0oEabFS0DAwMtRUMDEy0TW3tDDgck7NAQoaWBjrmhqb6RqbGJhzAQA=";
byte[] bytes = Convert.FromBase64String (test);
Console.Write ("Converted: " + bytes.Length + " bytes.");
I get: Converted: 98 bytes.
I don't know the .Net mail classes so well, but there must be a way to get hold of the attachment's (the Base64 encoded data) and then you can decode it easily.
We can chat again tomorrow.
Jacques
|
|
|
|
|
Yes, Base64 Encoded data always end with an = I think.
No, you must not remove the newline chars. That's part of how it's encoded.
Jacques
|
|
|
|
|
Sorry for the delay in response, i was off on friday, and my connection was a little laggy at home, so i couldnt work on the problem.
Ok, so i tried decoding it your way, and it works ok
When i compare the bytes to the origional files bytes, they are different.
Decode bytes:
2 0 0 0 255 255 115 79 205 47 74 79 85 112 74 45 42 170 228 10 73 205 73 45 41 74 76 78 45 82 208 8 40 169 212 84 240 41 73 225 114 205 77 204 204 81 72 7 171 115 40 129 171 208 75 206 215 171 74 4 105 177 82 208 48 48 50 212 84 48 49 50 209 53 183 180 48 224 114 78 205 1 10 26 88 24 235 154 26 155 233 26 155 24 152 115 1 0
Origional file's bytes:
2 0 0 0 253 253 115 79 253 47 74 79 85 112 74 45 42 253 253 10 73 253 73 45 41 74 76 78 45 82 253 8 40 253 253 84 253 41 73 253 114 253 77 253 253 81 72 7 253 115 40 253 253 253 75 253 235 74 4 105 253 82 253 48 48 50 253 84 48 49 50 253 53 253 253 48 253 114 78 253 1 10 26 88 24 253 253 26 253 253 26 253 24 253 115 1 0
as you can imagine, it doesnt unzip.
|
|
|
|
|
I created a DataTable thru coding and store some rows/data in it.
After that I want to select "Distinct" data from this table.
Datatable dt;
dt.Select("DISTINCT column1");
its saying ="Missing operand after column1 operator"
I want to select DISTINCT rows from this dt table but its not working,
I am using vs2003.
|
|
|
|
|
The DataTable has no built in support for this, you'll basically have to roll your own.
Check out this article: Select DISTINCT on DataTable[^]
Your other option would of course be to just grab all the rows using DataTable.Select() then de-dupe the returned array.
|
|
|
|
|
I have a pixel array -
1-D byte array, with each 4 bytes representing B G R A componenets of a pixel.
I want to convert this to an image and render it on screen.
What Class should I be using to
1) Conver to image
2) Render image
|
|
|
|
|
Use this, for example:
Put picturebox on screen:
Bitmap bitmap = new Bitmap(10, 10);
bitmap.SetPixel(1, 1, Color.FromArgb(255, 255, 255));
bitmap.SetPixel(2, 2, Color.FromArgb(100, 200, 80));
pictureBox1.Image = bitmap;
|
|
|
|
|
That is a very inefficient method for large images.
A better method would be
BitmapSource bs = BitmapSource.Create(
(int)size.Width,
(int)size.Height,
96d,
96d,
PixelFormats.Bgra32,
null,
pixels,
stride);
Image image = new Image();
image.Source = bs;
canvas2.Children.Add(image);
|
|
|
|
|
I don't see any System.Windows.Media.Imaging.BitmapSource in .NET 2.0.
What kind of .NET are you using ?
|
|
|
|
|
That's WPF, "Supported in: 3.5, 3.0 SP1, 3.0"
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi, i have this main form(mdi). When i open a form, called "EditQty",
childEditQty.parent = this;
then within the editqty, i want to open 1 more form and i want to set the parent to the mainForm,
childSelectedQty = new FrmSelectedQty();
childSelectedQty.MdiParent = EBMS.FrmMain();
childSelectedQty.Show = true;
i cannot set childSelectedQty.MdiParent = EBMS.FrmMain(); to 'this' because this itself its a child form, how do i reference back to set the mdiparent to the main form
|
|
|
|
|
childEditQty.Parent references the frmMain so use that.
[edit] i.e. childSelectedQty.MdiParent = this.Parent;
or childSelectedQty.MdiParent = this.MdiParent; [/edit]
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|