怎么样在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# picturebox 绘图问题!急!!! 请问如何对软件进行加密 请教各位高手,页面间的控制? 未将对象引用设置到到对象的实例 WPF中,怎么创建dll类库? DataTable导出到EXCEL2010,这段代码只能导出.xls 而不能导出后缀名为.xslx??求大神帮助 存储过程执行不成功 ListView是View.Details 模式的时候,怎么把图标放在网格里面 如何得到datagrid某个cell对应的数据对象 两个不同的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;//这里有些问题啊??
}