Click here to Skip to main content
15,921,905 members
Home / Discussions / C#
   

C#

 
QuestionUDP/IP sockets Pin
NaNg152417-Oct-06 10:21
NaNg152417-Oct-06 10:21 
QuestionInserting data from datagrid into Sql server Pin
engineer_ali7-Oct-06 7:46
engineer_ali7-Oct-06 7:46 
QuestionHow to print Datagrid in C# 2005 ? Pin
hdv2127-Oct-06 7:37
hdv2127-Oct-06 7:37 
AnswerRe: How to print Datagrid in C# 2005 ? Pin
Nader Elshehabi8-Oct-06 6:47
Nader Elshehabi8-Oct-06 6:47 
Questioncommand line usage of csc Pin
waheed awan7-Oct-06 7:16
waheed awan7-Oct-06 7:16 
AnswerRe: command line usage of csc Pin
Daniel Monzert7-Oct-06 21:20
Daniel Monzert7-Oct-06 21:20 
QuestionHelp - Send a File via Socket Pin
FlyOnIT7-Oct-06 5:49
FlyOnIT7-Oct-06 5:49 
AnswerRe: Help - Send a File via Socket Pin
Andrei Ungureanu7-Oct-06 7:34
Andrei Ungureanu7-Oct-06 7:34 
Hy,

You don't need to send a file with the Send File method. The send method send a byte array. So use FileStream to read the byte content of the file and then send it to the client/server
//read the file
FileStream fstream = File.Open(filename,FileMode.Open);
byte []buffer = new byte[fstream.Lenght];
fstream.Read(buffer,0,buffer.Length);
fstream.Close();

//send it
ClientSocket.Send(buffer);


It works fine on any kind of files. After you have received the file use FileStream to write the file (of course you should know the extension to put to the file).

Hope it helps



Do your best to be the best

GeneralRe: Help - Send a File via Socket Pin
FlyOnIT7-Oct-06 8:31
FlyOnIT7-Oct-06 8:31 
GeneralRe: Help - Send a File via Socket Pin
Andrei Ungureanu7-Oct-06 8:51
Andrei Ungureanu7-Oct-06 8:51 
GeneralRe: Help - Send a File via Socket Pin
FlyOnIT7-Oct-06 10:09
FlyOnIT7-Oct-06 10:09 
GeneralRe: Help - Send a File via Socket Pin
FlyOnIT8-Oct-06 1:14
FlyOnIT8-Oct-06 1:14 
GeneralRe: Help - Send a File via Socket Pin
FlyOnIT8-Oct-06 8:52
FlyOnIT8-Oct-06 8:52 
Questionmicrosoft agent Pin
Mohammed Elkholy7-Oct-06 5:19
Mohammed Elkholy7-Oct-06 5:19 
QuestionHow do I submit a book review? Pin
Wolf927-Oct-06 5:12
Wolf927-Oct-06 5:12 
QuestionHelp Parsing HTML/String Pin
UFGrayMatter7-Oct-06 4:02
UFGrayMatter7-Oct-06 4:02 
AnswerRe: Help Parsing HTML/String Pin
Guffa7-Oct-06 11:49
Guffa7-Oct-06 11:49 
GeneralRe: Help Parsing HTML/String Pin
UFGrayMatter7-Oct-06 11:57
UFGrayMatter7-Oct-06 11:57 
AnswerRe: Help Parsing HTML/String Pin
Guffa7-Oct-06 12:16
Guffa7-Oct-06 12:16 
QuestionInheriting from the tabcontrol Pin
thepersonof7-Oct-06 3:01
thepersonof7-Oct-06 3:01 
AnswerRe: Inheriting from the tabcontrol Pin
Captain See Sharp7-Oct-06 4:12
Captain See Sharp7-Oct-06 4:12 
GeneralRe: Inheriting from the tabcontrol Pin
thepersonof13-Oct-06 10:48
thepersonof13-Oct-06 10:48 
QuestionFiles in folder Pin
Mohammed Elkholy7-Oct-06 2:48
Mohammed Elkholy7-Oct-06 2:48 
AnswerRe: Files in folder Pin
DownBySpj7-Oct-06 3:06
DownBySpj7-Oct-06 3:06 
QuestionRaising events in C# Pin
Mahhouraaaaaa7-Oct-06 1:44
Mahhouraaaaaa7-Oct-06 1:44 

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.