|
string strComputer = "atl-ws-01";
objGroup = GetObject(@"WinNT://" + strComputer + @"/Administrators");
foreach( objUser In objGroup.Members)
{
if( (objUser.Name != "Administrator") && (objUser.Name != "Domain Admins"))
objGroup.Remove(objUser.AdsPath);
}
Ahsan Ullah
Senior Software Engineer
|
|
|
|
|
Ahsan, thank you very much for the reply, can you please tell me what should be the data type of variable objGroup and how to use objGroup in foreach loop.
Thanks a lot,
Mushq
Regards,
Mushq
|
|
|
|
|
Good Day,
What is the best way to transfer files from C# to a Mobile phone? I need to transfer a small XML file.
Thanks!
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.
|
|
|
|
|
There are two ways of doing this, and I've done both in applications before.
The easiest way is to use ActiveSync (XP and earlier) or Windows Mobile Device Centre (WMDC) for copy the file you with a folder that is synced with the device. The benefit of this method is you simply write to a regular file on the desktop system, and it doesn't matter if the mobile device is connected or not. Worst case, the file is synced across next time the device connects.
The second way, which involves a little more work is to use RAPI.DLL (you still need ActiveSync or WMDC) installed to do this. The API in RAPI.DLL allows you to connect to a device through C# and copy information to and from the device. Your best bet here would be to look at the RAPI docs on MSDN, or look at a framework from OpenNETCF Consulting which from memory, is free.
------------------------
Luke Lovegrove
------------------------
|
|
|
|
|
Thanks for the reply, Luke.
Sorry for not making things clear enough.
What I would like to accomplish is not a PC <-> Mobile transfer, but a Server-Client architecture.
SERVER <--> [WIRELESS ROUTER] <--> MOBILE CLIENTS
So the Clients (MOBILE) will request for the XML file from the server, the server in turn will respond by sending the XML file from the requesting client.
Please advice. I'm thinking of using web service for this and thought that others here may have a better solution.
Thanks!
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.
modified on Thursday, August 7, 2008 9:11 AM
|
|
|
|
|
Yeah, I'd probably suggest a web service of sorts for that. Keeping it as simple as possible is always the best thing to do, especially with mobile devices.
You could hit the server directly rather than through a web service if you were so inclined as well. I haven't used the Syetem.Net namespace much on desktops or mobile devices, but I suspect it would be a bit easier code wise to request it through a web service.
------------------------
Luke Lovegrove
------------------------
|
|
|
|
|
Hi All,
Can you please give me the equivalent code in C# for the following?
unsigned char CardType[2];
stu = MF_Request(DeviceAddr, 0, CardType);
Message("Request Card", stu);
String str;
char code[100];
if (stu == 0)
{
str = " ==> CardType(Hex): ";
sprintf(code,"%02X%02X",CardType[0],CardType[1]);
str += code;
}
Thanks in Advance
shahtech
|
|
|
|
|
What's the problem? If you have an equivalent for the MF_Request function (which I have no idea what it is), the translation is trivial.
|
|
|
|
|
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.
|
|
|
|