Click here to Skip to main content
15,888,334 members
Home / Discussions / C#
   

C#

 
AnswerRe: Basic Insert Row Question Pin
RaviRanjanKr13-Jun-11 2:48
professionalRaviRanjanKr13-Jun-11 2:48 
AnswerRe: Basic Insert Row Question Pin
BobJanova13-Jun-11 3:25
BobJanova13-Jun-11 3:25 
AnswerRe: Basic Insert Row Question Pin
AmbiguousName13-Jun-11 18:34
AmbiguousName13-Jun-11 18:34 
Questionhow to monitor downloaded and uploaded data Pin
Aisha sharma12-Jun-11 22:17
Aisha sharma12-Jun-11 22:17 
QuestionHow to create xml file in disk location using SQL Server 2005 & C#...? Pin
Manish_Kumar_Nayak12-Jun-11 21:03
Manish_Kumar_Nayak12-Jun-11 21:03 
AnswerRe: How to create xml file in disk location using SQL Server 2005 & C#...? Pin
Richard MacCutchan12-Jun-11 23:46
mveRichard MacCutchan12-Jun-11 23:46 
AnswerRe: How to create xml file in disk location using SQL Server 2005 & C#...? Pin
jschell13-Jun-11 8:43
jschell13-Jun-11 8:43 
QuestionGetting data from host, convert to string and then to bytes again. Pin
krosty478212-Jun-11 13:06
krosty478212-Jun-11 13:06 
Hi.
I want to make a program to download files from a remote host.
So what i do is to send throw sockets all the binary information + a string used as end "mystyring".
To check if i have to continue writing the buffer to the file i first convert all to string, so if i find "mystring" it will finish, if not, i reconvert all to bytes and i copy data.
The problem im having is that, .txt files are writed well, but binaris not, it always show error at opening. I ve tried copying a pdf, and when i open it show all the pages, but in blank . Also if i check the size of the original file is always some bytes bigger than the copy.

FileStream fs = new FileStream("C:\\Users\\Mauri\\Desktop\\" + item.Name, FileMode.Append, FileAccess.Write);
            BinaryWriter writer = new BinaryWriter(fs);
            bool continua = true;
            while (continua)
            {
                recibido = getSocket(numsock).socketRecv(); // This return the data converted to string.
                words = recibido.Split('|'); //We split "|mystring" to find the end of file.
                foreach (string s in words)
                {
                    if ((String.Compare(s, "mystring") != 0))                        
                        writer.Write(StringToBytes(s)); // Write converted data. 
                    else
                        continua = false; // if we find "mystring", end the action.
                }   
            }
            writer.Close();
            fs.Close();

// Convert string to bytes
public byte[] StringToBytes(String cadena)
        {
            System.Text.ASCIIEncoding codificador = new System.Text.ASCIIEncoding();
            return codificador.GetBytes(cadena);
        }


The strange thing is that .txt files are writed correctly.
I can't use webclient class, beacuse im not downloading the data from an http or ftp server, is for a connection between 2 computers, like a remote access program.

Thanks
AnswerRe: Getting data from host, convert to string and then to bytes again. Pin
Luc Pattyn12-Jun-11 13:42
sitebuilderLuc Pattyn12-Jun-11 13:42 
GeneralRe: Getting data from host, convert to string and then to bytes again. Pin
krosty478212-Jun-11 15:07
krosty478212-Jun-11 15:07 
AnswerRe: Getting data from host, convert to string and then to bytes again. Pin
Luc Pattyn12-Jun-11 15:21
sitebuilderLuc Pattyn12-Jun-11 15:21 
GeneralRe: Getting data from host, convert to string and then to bytes again. Pin
krosty478215-Jun-11 12:53
krosty478215-Jun-11 12:53 
AnswerRe: Getting data from host, convert to string and then to bytes again. Pin
Luc Pattyn12-Jun-11 15:34
sitebuilderLuc Pattyn12-Jun-11 15:34 
GeneralRe: Getting data from host, convert to string and then to bytes again. Pin
BobJanova13-Jun-11 0:05
BobJanova13-Jun-11 0:05 
QuestionUsing Cobol Copy Books Pin
MumbleB11-Jun-11 0:53
MumbleB11-Jun-11 0:53 
AnswerRe: Using Cobol Copy Books Pin
PIEBALDconsult11-Jun-11 3:33
mvePIEBALDconsult11-Jun-11 3:33 
AnswerRe: Using Cobol Copy Books Pin
Luc Pattyn11-Jun-11 3:53
sitebuilderLuc Pattyn11-Jun-11 3:53 
GeneralRe: Using Cobol Copy Books Pin
PIEBALDconsult11-Jun-11 6:09
mvePIEBALDconsult11-Jun-11 6:09 
AnswerRe: Using Cobol Copy Books Pin
Luc Pattyn11-Jun-11 6:27
sitebuilderLuc Pattyn11-Jun-11 6:27 
GeneralRe: Using Cobol Copy Books Pin
PIEBALDconsult11-Jun-11 14:03
mvePIEBALDconsult11-Jun-11 14:03 
AnswerRe: Using Cobol Copy Books Pin
Not Active11-Jun-11 5:29
mentorNot Active11-Jun-11 5:29 
GeneralRe: Using Cobol Copy Books Pin
MumbleB11-Jun-11 6:53
MumbleB11-Jun-11 6:53 
AnswerRe: Using Cobol Copy Books Pin
DaveyM6911-Jun-11 10:19
professionalDaveyM6911-Jun-11 10:19 
QuestionPrintPreviewControl and HTML Pin
dSolariuM10-Jun-11 23:36
dSolariuM10-Jun-11 23:36 
AnswerRe: PrintPreviewControl and HTML Pin
Luc Pattyn11-Jun-11 0:11
sitebuilderLuc Pattyn11-Jun-11 0:11 

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.