|
absolutely right...
somehow it was generated twice in designer code....
thanks
|
|
|
|
|
Btw, how about char.ToLower ?
|
|
|
|
|
right, much simpler
thanks
|
|
|
|
|
FYI: the KeyDown/KeyUp events don't, but the KeyPress event offers a KeyPressEventArgs.KeyChar holding the character in its correct casing for free... however it only fires for keys that contribute to document content, not modifier keys such as shift, control, alt, ...
|
|
|
|
|
so how this casing can help me ?
|
|
|
|
|
I suggest you read the documentation, and try it.
|
|
|
|
|
after msdn review, the KeyPress event doesn't help me, cause i don't need to filter the input
thanks anyway
|
|
|
|
|
...here is the relevant code code:
private static void WriteArchive(string document, MessageType outboundInfo, string filePath, FtpWebRequest request)
{
try
{
using (MemoryStream memoryStream = new MemoryStream(document.Length))
{
int bufferSize = document.Length;
byte[] buffer = new byte[bufferSize];
UnicodeEncoding encoding = new UnicodeEncoding();
byte[] _document = encoding.GetBytes(document);
memoryStream.Write(_document, 0, _document.Length);
memoryStream.Seek(0, SeekOrigin.Begin);
request.Method = WebRequestMethods.Ftp.UploadFile;
request.UsePassive = true;
request.UseBinary = false;
request.KeepAlive = false;
using (Stream stream = request.GetRequestStream())
{
int content = memoryStream.Read(buffer, 0, bufferSize);
while (content != 0)
{
stream.Write(buffer, 0, content);
content = memoryStream.Read(buffer, 0, bufferSize);
}
}
}
}
catch (Exception ex)
{
throw ex;
}
}
When I stepped through, there were 2 executions of the loop. I was kind of puzzled by it, because I had set the buffersize to accept the whole enchilada. So, I stepped through again, and on memoryStream.Read, every other byte inside buffer is '0' . ...After the file was written, I opened it up in Notepad++ and confirmed that NULLS were being inserted into the file. Did I just do something stupid? Anyone know how to cull those NULL characters?
"I need build Skynet. Plz send code"
|
|
|
|
|
Yup!! It was stupid alright. I had to paste my code in here before I even noticed it....I configured UnicodeEncoding when I obviously need my encoding to be ASCIIEncoding()
I'll leave this here so google searches might find it - remember that you need ASCIIEncoding if you're trying to upload an xml file lol
"I need build Skynet. Plz send code"
|
|
|
|
|
I am trying to figure out how I can properly support multiple (& identical) events using a single delegate/handler. What I am experiencing is that I can easily tied my events to a single handler (i.e., using += ), but when any one of the events fire each instance of the handler method executes. I did not expect this behaviour as I had assumed that each delegate creation was instantiating a specific copy of itself and would be internally resolved. I have a full project space that shows this behaviour. Here is some code from the main program that shows the overall structure that I currently have:
namespace EventsDelegateIssue
{
public partial class MainForm : Form
{
#region - Variables -
DoSomeWork[] oDoSomeWork;
delegate void SetMessageCallback(string Message);
#endregion
#region - Constructor/Destructor -
public MainForm()
{
InitializeComponent();
//Create some worker objects and connect their events to handlers
oDoSomeWork = new DoSomeWork[3];
for (int i = 0; i < oDoSomeWork.Length; i++)
{
oDoSomeWork[i] = new DoSomeWork();
oDoSomeWork[i].Index = i;
oDoSomeWork[i].OnMessage += new PostMessageEvent.OnMessageEvent(MainForm_OnMessage);
onMessage_event += new onMessage_delegate(onMessage_method);
oDoSomeWork[i].OnData += new RaiseDataEvent.OnRaiseDataEvent(MainForm_OnData);
onData_event += new onData_delegate(onData_method);
}
}
#endregion
#region - Form Control Event Handler(s) -
private void btnDoSomeWork_Click(object sender, EventArgs e)
{
//Let's start our worker objects such that [0] finishes first, [2] second, and [1] third
oDoSomeWork[0].Count(10);
oDoSomeWork[1].Count(50);
oDoSomeWork[2].Count(20);
}
#endregion
#region - DoSomeWork Event Handlers -
//These worker event handlers check to make sure that they can handle the task on the proper thread
//Handle worker generated messages
public delegate void onMessage_delegate(PostMessageEvent messageHandler);
private event onMessage_delegate onMessage_event;
private void MainForm_OnMessage(PostMessageEvent messageHandler)
{
if (this.InvokeRequired == true)
{ BeginInvoke(onMessage_event, new object[] { messageHandler }); }
else
{ onMessage_method(messageHandler); }
}
private void onMessage_method(PostMessageEvent messageHandler)
{ UpdateMessage(messageHandler.strMessage); }
//Handle worker generated data
public delegate void onData_delegate(RaiseDataEvent dataEvent);
private event onData_delegate onData_event;
private void MainForm_OnData(RaiseDataEvent dataEvent)
{
if (this.InvokeRequired == true)
{ BeginInvoke(onData_event, new object[] { dataEvent }); }
else
{ onData_method(dataEvent); }
}
private void onData_method(RaiseDataEvent dataEvent)
{
UpdateMessage(dataEvent.Tag.ToString() + "; " + dataEvent.Data);
}
#endregion
#region - Update Message Function -
private void UpdateMessage(string Message)
{
//This message handler also checks to see if it is operating on the correct thread so as to
//not throw an exception
if (this.txtMessages.InvokeRequired)
{
SetMessageCallback d = new SetMessageCallback(UpdateMessage);
this.Invoke(d, new object[] { Message });
}
else
{ txtMessages.AppendText(DateTime.Now.ToString("HH:mm:ss") + "=> " + Message + "\r\n"); }
}
#endregion
}
}
|
|
|
|
|
Delegate derives from MultiCastDelegate[^] so this is expected behavior.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Ok, do you have any advice on how to tie multiple & identical events to a single delegate method such that on any one event firing the delegate method can be made to execute only once?
|
|
|
|
|
|
if you allow I want to know what that means intruction;
Persone pers1;
knowing that Persone is a class
thank you
|
|
|
|
|
membre123 wrote: what that means intruction;
Persone pers1;
It simply instructs the compiler to reserve enough space to hold a reference to an instance of the class (Persone in this case) which can then be referred to by the name pers1.
That's about it. It does nothing else.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
|
|
Hello,
somebody can help me to find a source code that runs for authentication by usb key.
please is very urgent, thank you in advance.
Regards
|
|
|
|
|
i think that there's another subject called "authentication token", but never works for me !!!
|
|
|
|
|
Hi taztazon,
yes i know, but it doesn't work, somebody help me
pleaaaase
|
|
|
|
|
Have you tried to google this? See This Link[^] below. There are a number of posts discussing this.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
hi kwagga,
I have not found soory.
another proposal?
|
|
|
|
|
Please stop reposting.
Maurinho0 wrote: is very urgent
Not to us it ain't.
|
|
|
|
|
|
Any particular kind of USB key? Are you talking about a specific device? A thumbdrive with a particular file on it? If it is really that urgent I would suggest you give more information so that people don't have to do a lot of work to try to help you.
|
|
|
|