怎么样在C#中传送和接收一个文件?? 指Ftp吗??看这儿:http://www.codeproject.com/csharp/net_ftp_upload.asp?target=ftp 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 FileStream fs = new FileStream(sbFilenameD.ToString(), FileMode.Open, FileAccess.Read); BinaryReader fileReader = new BinaryReader(fs); byte[] bytes = new byte[1024]; int hasRead; while((hasRead = fileReader.Read(bytes, 0, bytes.Length)) != 0) { tcpStream.Write(bytes, 0, hasRead); } bytes = Encoding.ASCII.GetBytes("<EOF>"); tcpStream.Write(bytes, 0, bytes.Length); fileReader.Close(); 这是发送的 FileStream fs = new FileStream(localFilename, FileMode.OpenOrCreate); BinaryWriter w = new BinaryWriter(fs); Byte[] read = new Byte[1024]; int index; while( (bytes = tcpStream.Read(read, 0, read.Length)) != 0) //2 { if(bytes != 1024 && (index = Encoding.ASCII.GetString(read).IndexOf("<EOF>")) > -1 ) { w.Write(read, 0, index); break; } w.Write(read, 0, bytes); read = new Byte[1024]; } w.Close(); fs.Close();这是接受的都是从我的程序里直接拖出来的,所以有些变量名什么的定义在前面的,看不到 通过Socket,用数据流传大字节 haha,一切都已经搞定。就差最后的怎么把文件流输出成文件了。使用SaveFileDialog???怎么用呢,现在已有待变成文件的文件流fout.3ks! DialogResult answer = saveFileDialog1.ShowDialog();if(answer!=DialogResult.Cancel){ saveFileDialog1.FileName;} DialogResult answer = saveFileDialog1.ShowDialog();if(answer!=DialogResult.Cancel){ saveFileDialog1.FileName;//这里有些问题啊??} http://xml.sz.luohuedu.net/xml/ShowDetail.asp?id=D8F961C3-CBC1-4591-143D-236B572EB89Fhttp://xml.sz.luohuedu.net/xml/ShowDetail.asp?id=CDBAB4E8-0938-4134-B86F-3B9E2C396E8D 想做一个C#看门狗的程序,求教高手 C# 生成新数据库 c#小问题 c# 窗體傳值 关于asp.net在线统计人数 string型的16进制文本转byte[]代码的问题! 是MDI的问题吗? 请问各位高手:ftp上传和http上传两种的优缺点各是什么? 动态数组 如何创建二进制文件? 两个不同的CS文件,一个要调用另外一个文件的变量,两个文件不在一个模块里怎么做 如何在代码中动态产生控件,使其均匀的排列在Web页面中?
BinaryReader fileReader = new BinaryReader(fs);
byte[] bytes = new byte[1024];
int hasRead; while((hasRead = fileReader.Read(bytes, 0, bytes.Length)) != 0)
{
tcpStream.Write(bytes, 0, hasRead);
}
bytes = Encoding.ASCII.GetBytes("<EOF>");
tcpStream.Write(bytes, 0, bytes.Length);
fileReader.Close(); 这是发送的
BinaryWriter w = new BinaryWriter(fs);
Byte[] read = new Byte[1024];
int index;
while( (bytes = tcpStream.Read(read, 0, read.Length)) != 0) //2
{
if(bytes != 1024 && (index = Encoding.ASCII.GetString(read).IndexOf("<EOF>")) > -1 )
{
w.Write(read, 0, index);
break;
} w.Write(read, 0, bytes);
read = new Byte[1024];
}
w.Close();
fs.Close();这是接受的都是从我的程序里直接拖出来的,所以有些变量名什么的定义在前面的,看不到
使用SaveFileDialog???
怎么用呢,现在已有待变成文件的文件流fout.
3ks!
if(answer!=DialogResult.Cancel)
{
saveFileDialog1.FileName;
}
if(answer!=DialogResult.Cancel)
{
saveFileDialog1.FileName;//这里有些问题啊??
}