|
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)
|
|
|
|
|
Hi there,
I am curious as to what "n products" are available? I know of nunit, ncover, and ndepend. I'm just curious.
Brendan
|
|
|
|
|
This isn't really a C# question is it? You should put this in the General forum or the Lounge.
|
|
|
|
|
Search for ALT.NET - All these products are from different places - there is no unified list of n-products. However, the products you mentioned are heavily used by the ALT.NET community.
|
|
|
|
|
This question is "n appropriate" here.
|
|
|
|
|
Hi, i got 2 list view on 1 form. the first list view shows the product name and the other listview show the supplier name.
the user have to first select a item from the product list view , then select another item from the supplier list view.
By now, both selected items should be highlighted.
When i press the ok button, i wan to know in product list box, what the user selected and in the supplier list box, what the user selected.
However when i select 1 item from product, then i select the other item from supplier, the product list view is being disselected
DataTable dt = new DataTable();
dt = pa.GetData();
foreach (DataRow rows in dt.Rows)
{
ListViewItem product = new ListViewItem();
product = listView1.Items.Add(Convert.ToString(rows["productID"]));
product.SubItems.Add(Convert.ToString(rows["name"]));
product.SubItems.Add(Convert.ToString(rows["modelNo"]));
}
DataTable dt1 = new DataTable();
dt1 = sa.GetData();
foreach (DataRow rows in dt1.Rows)
{
ListViewItem supplier = new ListViewItem();
supplier = listView2.Items.Add(Convert.ToString(rows["companyName"]));
supplier.SubItems.Add(Convert.ToString(rows["contactName"]));
}
|
|
|
|
|
Hi.
Try setting
ListView.HideSelection = false;
Kjetil
|
|
|
|