Click here to Skip to main content
15,923,015 members
Home / Discussions / C#
   

C#

 
GeneralRe: key_down event fired twice Pin
igalep1326-May-10 11:26
igalep1326-May-10 11:26 
GeneralRe: key_down event fired twice Pin
harold aptroot6-May-10 11:30
harold aptroot6-May-10 11:30 
GeneralRe: key_down event fired twice Pin
igalep1326-May-10 11:36
igalep1326-May-10 11:36 
AnswerRe: key_down event fired twice Pin
Luc Pattyn6-May-10 11:37
sitebuilderLuc Pattyn6-May-10 11:37 
GeneralRe: key_down event fired twice Pin
igalep1326-May-10 11:47
igalep1326-May-10 11:47 
GeneralRe: key_down event fired twice Pin
Luc Pattyn6-May-10 11:55
sitebuilderLuc Pattyn6-May-10 11:55 
GeneralRe: key_down event fired twice Pin
igalep1326-May-10 12:09
igalep1326-May-10 12:09 
QuestionFtpWebRequest - (UploadFile) every other character is NULL Pin
Alaric_6-May-10 10:30
professionalAlaric_6-May-10 10:30 
...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))
                {
                    //configure a buffer for reading data after document is streamed
                    int bufferSize = document.Length;
                    byte[] buffer = new byte[bufferSize];
                    UnicodeEncoding encoding = new UnicodeEncoding();
                    byte[] _document = encoding.GetBytes(document);

                    //stream document and reset memoryStream's internal position pointer
                    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())
                    {
                        //now pointing to the FtpWebRequest's internal stream
                        int content = memoryStream.Read(buffer, 0, bufferSize);
                        while (content != 0)
                        {   //write contents of memoryStream out to FtpWebRequest
                            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"

AnswerRe: FtpWebRequest - (UploadFile) every other character is NULL Pin
Alaric_6-May-10 10:34
professionalAlaric_6-May-10 10:34 
QuestionIssue With Multiple Events Handled By One Delegate ... Pin
Mrestivo6-May-10 6:11
Mrestivo6-May-10 6:11 
AnswerRe: Issue With Multiple Events Handled By One Delegate ... Pin
Not Active6-May-10 7:00
mentorNot Active6-May-10 7:00 
GeneralRe: Issue With Multiple Events Handled By One Delegate ... Pin
Mrestivo6-May-10 7:56
Mrestivo6-May-10 7:56 
GeneralRe: Issue With Multiple Events Handled By One Delegate ... Pin
Not Active6-May-10 8:21
mentorNot Active6-May-10 8:21 
Questionvariable type class Pin
tek 20096-May-10 5:24
tek 20096-May-10 5:24 
AnswerRe: variable type class Pin
Henry Minute6-May-10 5:40
Henry Minute6-May-10 5:40 
AnswerRe: variable type class Pin
harold aptroot6-May-10 5:44
harold aptroot6-May-10 5:44 
GeneralRe: variable type class Pin
tek 20096-May-10 5:50
tek 20096-May-10 5:50 
QuestionAuthentication Token USB Pin
Maurinho06-May-10 3:40
Maurinho06-May-10 3:40 
AnswerRe: Authentication Token USB Pin
taztazon6-May-10 3:45
taztazon6-May-10 3:45 
GeneralRe: Authentication Token USB Pin
Maurinho06-May-10 3:59
Maurinho06-May-10 3:59 
AnswerRe: Authentication Token USB Pin
MumbleB6-May-10 4:03
MumbleB6-May-10 4:03 
GeneralRe: Authentication Token USB Pin
Maurinho06-May-10 4:47
Maurinho06-May-10 4:47 
AnswerRe: Authentication Token USB Pin
PIEBALDconsult6-May-10 4:33
mvePIEBALDconsult6-May-10 4:33 
GeneralRe: Authentication Token USB Pin
taztazon6-May-10 4:44
taztazon6-May-10 4:44 
AnswerRe: Authentication Token USB Pin
T M Gray6-May-10 11:27
T M Gray6-May-10 11:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.