|
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
I was able to finally get this to nightmare to work.
This is so weird because I would have thought that all I needed to do would be do a .ReadToEnd(); but this just made
the app hang up.
So I have had to do this see saw type of push pull the stream until I get the data that I am looking for.
public bool CheckIfDomainZoneNodeHasRecords(string server, string zone, string node)
{
//
Process myProcess = null;
ProcessStartInfo myProcessStartInfo = null;
StreamReader myStreamReader = null;
string cmdFailed = string.Empty;
string dnsCmd = string.Empty;
StringBuilder output = null;
try
{
cmdFailed = "DNS Server failed";
//string cmdCompleted = "command completed successfully";
//Command failed: DNS_ERROR_NAME_DOES_NOT_EXIST 9714
//cmd server cmd zone node
//dnscmd afcc-inc-ns1 /enumrecords AFCCINC.COM handlers
dnsCmd = string.Format("dnscmd {0} /enumrecords {1} {2}", server, zone, node);
output = new StringBuilder();
myProcess = new Process();
myProcessStartInfo =
new ProcessStartInfo("cmd.exe");
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.CreateNoWindow = true;
myProcessStartInfo.RedirectStandardOutput = true;
myProcessStartInfo.RedirectStandardInput = true;
myProcessStartInfo.Arguments = dnsCmd;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
myStreamReader = myProcess.StandardOutput;
do
{
output.Append(myStreamReader.ReadLine() + "\n");
} while (myStreamReader.Peek() >= 0);
myProcess.StandardInput.WriteLine(dnsCmd);
do
{
output.Append(myStreamReader.ReadLine());
} while (myStreamReader.Peek() >= 0);
myProcess.StandardInput.WriteLine("\n");
do
{
output.Append(myStreamReader.ReadLine());
} while (myStreamReader.Peek() >= 0);
myProcess.StandardInput.WriteLine("\n");
do
{
output.Append(myStreamReader.ReadLine());
} while (myStreamReader.Peek() >= 0);
myProcess.StandardInput.WriteLine("\n");
do
{
output.Append(myStreamReader.ReadLine());
} while (myStreamReader.Peek() >= 0);
do
{
output.Append(myStreamReader.ReadLine());
} while (myStreamReader.Peek() >= 0);
myStreamReader.Close();
myProcess.Close();
Console.WriteLine(output.ToString());
if (output.ToString().ToLower().Contains(cmdFailed.ToLower()))
return false;//0
return true;
}
catch (Exception ex)
{
System.Net.Mail.MailMessage mm = null;
SmtpClient smtp = null;
mm =
new System.Net.Mail.MailMessage
(new System.Net.Mail.MailAddress("problems@afccDnsManager.com"),
new System.Net.Mail.MailAddress("support@afccinc.com"));
//
mm.Subject = "Problems with the AFCC Dns Manager Service";
mm.Body = "Message: " + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine;
mm.Body += "Source : " + Environment.NewLine + ex.Source;
smtp = new SmtpClient("smtp.afccinc.com");
smtp.Send(mm);
mm = null;
smtp = null;
//
return true;
}
finally
{
myProcess = null;
myProcessStartInfo = null;
myStreamReader = null;
cmdFailed = string.Empty;
dnsCmd = string.Empty;
output = null;
}
}
Any suggestion?
http://storefrontdoors.net
Erik
modified on Thursday, April 9, 2009 5:19 PM
|
|
|
|
|
Hi, I am trying to append text to a textbox in a form after clicking a button in another form. How do I access the textbox from the button click method?
Thank you.
|
|
|
|
|
Write a function in Form2 that can be called by Form1. The function should accept a string, and set the appropriate control that that string value.
You may now go forth, and write code.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Thank you! Totally forgot about that.
|
|
|
|
|
Im planning that when the form loads it is invisible. So what i did was in the constructor of the FORM I called the form or set the form to hide by setting the VISIBLE property to false or called the hide function. It doesnt work.. so I used the form load event, and i set the properties and or function there and it doesnt work.. so i used the form shown event, it worked but the problem is, the form shows then dissappears and its kinda look ugly that way.. what i want is that when executed the form is invisible without a trace.
|
|
|
|
|
Set the opacity to 0 in the form properties.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
It's a problem in your calling code, not the form itself. You can create a form by calling it's constructor, everything will happen then (if written properly) but it will not be visible.
|
|
|
|
|
if you want your form invisible, why use form? i mean how about just create an object that hold all information (field, method, properties) of your "invisible form".
hope it helps.
dhaim
programming is a hobby that make some money as side effect
|
|
|
|
|
The "why" is irrelevant. If you can't help the guy, refrain from posting.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Just make a suggestion. If you don't need a visual object why you use that?. You can create an object substantially similar of "invisible form" and you don't have to set Visible property to false.
dhaim
programming is a hobby that make some money as side effect
|
|
|
|
|
You don't see to get it. The original poster asked how to do something - NOT for alternatives to what he was doing or opinions about his coding. Answering someone's question AS POSTED is a lot more important that trying to prove you're clever (which you aren't).
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
so you are clever enough with your answer : 'Set the opacity to 0 in the form properties.'
don't be rude dude.
John Simmons / outlaw programmer wrote: a lot more important that trying to prove you're clever (which you aren't).
I don't need to prove that I'm clever or not. I know you are MVP in CP, IMO nothing special with your knowledge. In this forum, peoples can share all possible answer to help others as you do with writing all your articles. aren't you?
dhaim
programming is a hobby that make some money as side effect
|
|
|
|
|
John Simmons / outlaw programmer wrote: Answering someone's question AS POSTED is a lot more important that trying to prove you're clever
Many people don't know what to ask for, how to ask for it, or where to ask for it. If you only ever answer exactly what people ask for, you often can not give them the answer that they want, or the answer that they need.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I agree with you dude.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
Guffa wrote: Many people don't know what to ask for, how to ask for it, or where to ask for it
If a person's communication skills aren't adequate, maybe they should learn better English. That *is* the language used on this site.
Guffa wrote: If you only ever answer exactly what people ask for, you often can not give them the answer that they want, or the answer that they need.
How could that guys question have been interpreted as "give me an alternative". He wanted to set the form to be invisible when it started up. I gave him the solution to *that* question. I don't care why he wants to do it.
I do some pretty whacked out stuff myself (like most of us have), and I personally don't like being quizzed as to my motives, or have some nimrod in a foreign country second-guessing me - I just want an answer to the question I posted. If you can't get your pointed little heads around that concept, then please don't answer my questions.
In any case, this conversation doesn't belong in this forum.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
In MSDN guide convert array bytes to string, here code: Encoding.UTF8.GetString(byte[] bytes) VS2005 doesn't support convert one byte to string.
Anybody can I help me? or for example how to convert one byte to string. Although, may be use to Convert.ToString(byte) is correct, but I don't think so. Except, differently another way
Thank one so much!!!!
|
|
|
|
|
Encoding.UTF8.GetString(byte[] bytes) is working. did you try the method Tostring();
|
|
|
|
|
Just make a byte array with only this byte in it.
GetString(new byte[] { myByte });
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
If you encode a single character into bytes using the UTF-8 encoding, it can result in more than a single byte. It wouldn't make sense to have a method that decodes a single byte, as that would only work on a very limited part of the character set.
If you have a character that actually was encoded into a single byte, you just have to put that byte in an array to decode it.
If you are trying to decode data byte by byte, that doesn't work, as some characters may need more than one byte of the data.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa wrote: If you have a character that actually was encoded into a single byte, you just have to put that byte in an array to decode it.
If you have a character that was encoded into a single byte using UTF8, then it was an ASCII character.
Instead of allocating lots of small byte arrays, you can just do this:
char DecodeASCII(byte b)
{
if (b >= 128)
throw new ArgumentException("This is not a single-byte character");
else
return (char)b;
}
|
|
|
|
|
this is the code i use to encrypt the "ser.xml"and send it to the server.
but when trying to decrypt this at server i get the exception "Unable to cast object of type 'System.Security.Cryptography.RSACryptoServiceProvider' to type 'System.Security.Cryptography.SymmetricAlgorithm'."
private void encrypt_msgxml()
{
XmlDocument xmldoc = new XmlDocument();
XmlElement element_to_enc;
Rijndael sessionkey;
EncryptedXml enxml = new EncryptedXml();
byte[] encryp_bytes;
byte[] encrypt_keyarray;
EncryptedData encrypt_element;
xmldoc.PreserveWhitespace = true;
xmldoc.Load("ser.xml");
element_to_enc = xmldoc.GetElementsByTagName("message")[0] as XmlElement;
sessionkey = new RijndaelManaged();
sessionkey.KeySize = 256;
encryp_bytes = enxml.EncryptData(element_to_enc, sessionkey, false);
encrypt_element = new EncryptedData();
encrypt_element.Type = EncryptedXml.XmlEncElementUrl;
encrypt_element.EncryptionMethod = new EncryptionMethod(EncryptedXml.XmlEncAES256Url);
EncryptedKey encrypt_key = new EncryptedKey();
encrypt_keyarray = EncryptedXml.EncryptKey(sessionkey.Key, rrsa, false);
encrypt_key.CipherData = new CipherData(encrypt_keyarray);
encrypt_key.EncryptionMethod = new EncryptionMethodEncryptedXml.XmlEncRSA15Url);
encrypt_element.KeyInfo = new KeyInfo();
KeyInfoName kin = new KeyInfoName();
kin.Value = "cli_ser_pub_key";
encrypt_element.KeyInfo.AddClause(kin);
encrypt_element.KeyInfo.AddClause(new KeyInfoEncryptedKey(encrypt_key));
encrypt_element.CipherData.CipherValue = encryp_bytes;
EncryptedXml.ReplaceElement(element_to_enc, encrypt_element, false);
xmldoc.Save("test.xml");
}
this is the code to decrypt.(i have created the rsa object in the server )
public void decrypt_msgxml()
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.PreserveWhitespace = true;
xmlDoc.Load("test.xml");
EncryptedXml exml = new EncryptedXml(xmlDoc);
exml.AddKeyNameMapping("cli_ser_pub_key", rsa);
exml.DecryptDocument();
}
can you tell me the reason for this.
|
|
|
|
|
prasadbuddhika wrote: can you tell me the reason for this.
Before trying encryption, learn the difference between asynchronous and asymmetric. Neither of which you are using as far as I can tell.
|
|
|
|
|
this link[^] may helps
dhaim
programming is a hobby that make some money as side effect
|
|
|
|
|
Hi,
VS2005 Winforms.
Im creating a form which has a panel which can hold a number of different user controls.
The user control to display is decided at runtime.
To give a more professional look I want the user controls to fade into view.
Ive seen how this is possible on winforms using the opacity property.
Is there any way of achieving this on user controls also?
Many thanks,
Chas
|
|
|
|