|
accii value of enter key is 13
|
|
|
|
|
ASCII 13 is not the enter key - it is a CR (or carriage return) character. It indicates that the cursor should move to the left hand side, not that it should start a new line. It may, or may not, be in conjunction with the ASCII LF character depending on the system.
With a .DOC file, there is no guarantee that CR indicates anything, particularly the end of a paragraph as originally requested by the OP. Remember that Word 2007 changed the .DOC file format to an XML based paradigm where CR has no meaning whatsoever! Even before 2007, CR did not delimit a paragraph - see the .DOC file format, available on MSDN for details)You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
what kind protocol are using by socket?
|
|
|
|
|
Ok I have setup a simple gui for uart. I am trying to light up 4 LEDS thru a MC. LED0 will be 0x01, LED 1, 2, 3 will be 2, 4, 8. Will this send out the appropriate command I am looking for. I have no way to test it until tomorrow because I do not have the hardware with me but was wondering if this would suffice. I do not get any errors or warnings so I am thinking it should. Thanks
private void buttonLED0_Click_1(object sender, EventArgs e)
{
Data = Data ^= 0x01;
int BytesToWrite = Data;
int bytes = serialPort1.BytesToWrite;
buttonLED0.Enabled = !buttonLED0.Enabled;
if (buttonLED0.Enabled)
{
pictureBoxLED0.BackgroundImage = imageList1.Images[(int)LEDColor.GreenOn];
}
if (!buttonLED0.Enabled)
{
pictureBoxLED0.BackgroundImage = imageList1.Images[(int)LEDColor.RedOn];
}
}
|
|
|
|
|
By the way this will have to be sent out thru the TXD.
|
|
|
|
|
John-EE wrote: I do not get any errors or warnings so I am thinking it should.
It would be nice if not getting compile time errors or warnings meant that something would work.
The code you provided here doesn't look like it'll send anything out of the serial port. If it did, it would use the SerialPort.Write method. Take a look at msdn for details and examples.Standards are great! Everybody should have one!
|
|
|
|
|
I don't really know what the rest is about, but this is definitely odd:
John-EE wrote: Data = Data ^= 0x01;
This will only do something other than the more usual Data ^= 1 if Data is a property with side effects
|
|
|
|
|
harold aptroot wrote: if Data is a property with side effects
...which we are all really hoping it isn't. If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|
|
I spent one short evening last week defining a library of user controls for my project to track substation electrical equipment. I had found myself duplicating efforts creating various forms that use the same information, and found it tedious to switch back and forth tweaking properties to make the appearance consistent among forms. So I grouped various data items that I was recreating for each form and spent a few hours creating user controls in a library.
For example, a recloser has some basic nameplate information - serial #, manufacturer, type, etc. Reclosers also have a trip coil, and a close coil, and some but not all have ground trip coils. Each coil has its own voltage and current ratings, and a programmable sequence of trip-wait-close steps it can use to restore service on a faulted line. So I made a generic nameplate control, a coil control, and a sequence control. With these new controls I can play with the visibility properties to display only the elements that are relevant to a specific function or recloser type. At least, that was my plan.
Tonight I spent 30 seconds creating a test Form app, referenced my new library, and dragged the controls onto the form. It looks exactly the way I wanted it to, and behaves exactly as planned when I fiddle with the control properties! Now it's time to add controls to describe transformers, load tap changers, regulators, capacitors, and power circuit breakers to the library.
I'm jazzed! In 10+ years wasted trying to do something useful with Visual C++ I never managed to do this much at all, let alone in only a few hours!
Many thanks to all the patient helpers I've discovered here - programming is FUN again! "A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Did you mean to post this in the C# forum? Seems like it would make a good Lounge post.
|
|
|
|
|
It works either way, and this is where the folks who helped hang out. "A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
I am newbie to webservices
I am trying to learn about them, but got struck in the first place itself. Please help me out.
My service.cs in the web service.
--------------------------------
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
[WebService(Namespace = "http://localhost:1458/forumservices/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service () {
}
[WebMethod]
public string welcome(string name)
{
return "Welcome " + name;
}
}
now on a button click from another web page
protected void Button1_Click(object sender, EventArgs e)
{
try
{
soapMessage =
@"
<?xml version=""1.0"" encoding=""utf-8""?>
<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">
<soap12:Body>
<welcome xmlns=""http://localhost:1458/forumservices/"">
<name>Rajas</name>
</welcome>
</soap12:Body>
</soap12:Envelope>";
WebClient mClient = new WebClient();
Response.Write(System.Text.Encoding.ASCII.GetString(mClient.UploadData("http://localhost:1458/forumservices/Service.asmx", "POST", System.Text.Encoding.ASCII.GetBytes(soapMessage))));
}
catch (System.Net.WebException ex)
{
if (ex.Response != null)
{
Stream strm = ex.Response.GetResponseStream();
StreamReader sr = new StreamReader(strm);
Response.Write(sr.ReadToEnd());
}
else
{
Response.Write(ex.InnerException.ToString());
}
}
}
The compilation is fine, but i keep getting some errors as below
"The remote server returned an error: (500) Internal Server Error."
Please help me out
I had posted the exam same thing in ASP.NET forum, but got no replies.Jack Sparrow
--------------------------------------
Defeat is not the worst of failures. Not to have tried is the true failure.
|
|
|
|
|
|
if you wanted to change say textbox1 datasource to be that of checkbox1 datasource how would you go about doing that ? i looked for something like textbox1.datasource but didn't find anything. I know you can set it in properties but i wanted to set it in code if possible..
thanks
|
|
|
|
|
what do you mean by binding a textbox with datasource, you can simpley write textbox.text for binding any value in that.
|
|
|
|
|
well my original idea was that the reason one of my control was not populating correctly was because it was bound to a different binding source but I don't think that is problem at all. i used
textbox.databinding.add("Text",bindingnavigator.bindingsource,"SurrogateNumber"); then of course i get double binding errors when I do that because it is already bound. I don't know I'll figure something out. Kinda strange that the data comes back but that one control only gets the first instance of the filter whenever all the data is there.
Thanks for trying to help though.
|
|
|
|
|
I figured it out i had to use dataloadoptions to link all the tables together and it works fine.
|
|
|
|
|
i have created a encryption and decryption program. what i would like to do is have a CD with my decryption.exe program on it and a encrypted file. When the decryption.exe is launced i want to grab the encrypted file on the CD and either copy or move it to a location i specify on the C: drive. from here i will do the other necessary work. The problem i am having is when i tried to use either File.Copy or File.Move i am being thrown the error "Access E: drive is denied" (i am an admin on the computer). The question i have is it possible to move the encrypted file to the C: drive and if so could you point me in the right direction to do so. i would appreciate any help I'm really stuck here, also if you would like to see any code please let me know and i will post it here.
|
|
|
|
|
Erm, I'm just pointing this out, I don't know how your stuff works or where the Keys are stored or anything, but doesn't packaging up the encrypted information and the decryption tool break the security a little Antoine de Saint-Exupery: Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
|
|
|
|
|
yeh i see what your saying, basically the way i am controlling this is like this, the user will choose the file to be decrypted which will be on the on the CD, once they choose that file i want to move it to somewhere i specify on the C: drive then i will have the user click my decrypt button(where a new form is launched to input a password i supply(I'm using the password for both the iv and key) and it will decrypt and unzip the data and automatically launch a web browser in a form that is going to be linked to the index.html in the unzip folder.
after the new form or my program is closed i want to erase everything i created on the C: drive, i realize that security isn't perfect here but the fact is the end user can have the unencrypted data, but i understand what your saying packaging the decryption tool with the data is risky but without my password to decrypt the file its worthless. im using Aes 256 so its going to take some time to decrypt my password if some one really wanted it. hope i answered your question?
if not ill try again just ask away, thanks for the comment
|
|
|
|
|
Everything you need is in System.IO , for example the File class has Copy and Delete methods. Basic code would look like this:
string sourcePath = ".....";
string destinationPath = "......";
File.Copy(sourcePath, destinationPath);
File.Delete(destinationPath);
If I understand your post, there is still a problem with packaging up the decryption utility.
a) If your password is not the key then the encryption is only as good as the password strength (and the code to verify the password). It is also open to automated attempts at finding the password.
b) If you use both the key and the iv as the password, you need will need to send these as plain text to the user.
c) Along side b, Long keys are unlikely to be entered correctly by the user, short values are are susceptible to brute-force attacks).
d) You will need to obstifucate your decrypter to. PosssiblyAntoine de Saint-Exupery: Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
|
|
|
|
|
yes i have tried the File.Copy and the File.Move. i know the way i did them is right because if i run my program with the file on the C: drive and not a CD then it works. but when i try to get the file to copy or move from CD which happens to be my E: drive i get the error.
decryption failed Access to the path E:\bb.zip.dpa is denied.
if i have my encrypted file anywhere but on my CD then my program works fine. below is my code for when i open the file with a file browser dialog and here i try to copy the file. also i point out where it breaks and throws the Access is denied error
private void btnOpen_Click(object sender, EventArgs e)
{
ofdMain.Title = "Select file to Decrypt";
ofdMain.Filter = "Crypt files (*.dpa)|*.dpa";
if (ofdMain.ShowDialog() == DialogResult.OK)
{
txtBoxDecrypt.Text = ofdMain.FileName;
OutputFileNameDe();
string path = txtBoxDecrypt.Text;
string path2 = @"c:\temp2\MyTest.txt";
try
{
if (!File.Exists(path))
{
using (FileStream fs = File.Create(path)) {}
}
if (File.Exists(path2))
File.Delete(path2);
File.Move(path, path2);
Console.WriteLine("{0} was moved to {1}.", path, path2);
if (File.Exists(path))
{
Console.WriteLine("The original file still exists, which is unexpected.");
}
else
{
Console.WriteLine("The original file no longer exists, which is expected.");
}
}
catch (Exception ex)
{
Console.WriteLine("The process failed: {0}", ex.ToString());
}
}
}
thanks again for all your help, if i need to provide anything else let me know.
|
|
|
|
|
Aha! File.Move won't work as the CD is read-only and Move attempts to delete after copy. You should do a straight copy, then delete the temporary file when the decryption is done.
I'd also strongly suggest renaming your file paths something *like* SourcePath , TempFilePath and DecryptedFilePath as this saves a lot of potential pain if these get confused!
Another thing that occurs to me is, if memory serves, decryption happens in a stream, writing this out directly to the file via a FileStream would probably be more efficient than copy /decrypt/delete.Antoine de Saint-Exupery: Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
|
|
|
|
|
i just ran my app from a flash drive it worked perfect why am i getting access denied when i run my application and file from a CD???
|
|
|
|
|
A move would imply a "copy & delete" operation, and that would fail on a CD. Try again after you replace the File.Move with a File.Copy as keefb suggested I are Troll
|
|
|
|