asp教程.net file,filestream,byte应用转换
file>>>filestream (2种方式)
方式1:
filestream fs1 = file.open ( @"d:集团通知.jpg" , filemode.open );
方式2:
filestream fs2 = new filestream ( @"d:通知.jpg" , filemode.open );
filestream>>>byte[]
byte [ ] b1 = new byte [ fs1.length ];
fs1.read ( b1 , 0 , b1.length );
把文件保存到数据库教程中一般是file>>>filestream>>>byte[]
byte[]>>>file(2种方式)
假设byte[ ] b1里面有数据
方式1:
file.writeallbytes ( @"d:通知b2.jpg" , b1 );
方式2:
filestream fs = new filestream ( @"d:通知b_2.jpg" , filemode.openorcreate , fileaccess.write );
fs.write ( b1 , 0 , b1.length );
fs.close ( );
filestream>>>filestream
有时需要把文件流写到ftp的请求流中,实际上是利用byte[]做了一个缓冲区
stream requeststream = uploadrequest.getrequeststream ( );
filestream filestream = file.open ( @"d:abc.txt" , filemode.open );byte [ ] buffer = new byte [ 1024 ];
int bytesread;
while ( true )
{
bytesread = filestream.read ( buffer , 0 , buffer.length );
if ( bytesread == 0 )
break;
requeststream.write ( buffer , 0 , bytesread );
}
转换到filestream byte() array throws outofmemoryexception
'open the filestream data file for writing
dim fs as new sqlfilestream(filepath, txcontext, fileaccess.write)'open the source file for reading
dim localfile as new filestream("c:tempmicrosoftmouse.jpg",
filemode.open,
fileaccess.read)'start transferring data from the source file to filestream data file
dim bw as new binarywriter(fs)
const buffersize as integer = 4096
dim buffer as byte() = new byte(buffersize) {}
dim bytes as integer = localfile.read(buffer, 0, buffersize)while bytes > 0
bw.write(buffer, 0, bytes)
bw.flush()
bytes = localfile.read(buffer, 0, buffersize)
end while'close the files
bw.close()
localfile.close()
fs.close()
我的博物馆故事 官方安卓版v1.61.2
我的博物馆故事是一款以消除为主题的经营养成类手游,在这里玩家
专业模拟飞行10 手机版v12.2.4
专业模拟飞行10安卓版是一款飞行休闲手游,顶尖的物理飞行引擎
动物起义战斗模拟器二琳同款 最新版v4.1.1
动物起义战斗模拟器是一个非常有趣的模拟类游戏,玩家可以召唤各
迷你世界七周年 安卓手机版v1.43.0
迷你世界7周年是一款由《迷你世界》官方推出的庆祝特别版本,在
劫后公司无限资源版 v1.0.5.1
劫后公司内置菜单版是游戏的破解版本,在该版本中为玩家提供了内