The server reads the client files

1 to convert the file to a client obtains a file stream

FileStream fsRead = Form.edit.File.OpenRead();
int fsLen = (int)fsRead.Length;
byte[] heByte = new byte[fsLen];
int r = fsRead.Read(heByte, 0, heByte.Length);

 

2 bytes to the streaming server

 Convert.ToBase64String (heByte); // client into a string of bytes to the server

  byte [] buffer = Convert.FromBase64String (obj [ "byteStr"] ToString ().); // Converts a string to the server bytes

 

3 converts a byte stream as a maximal Stream and FileStream 

using (Stream stream = new MemoryStream(buffer))
{
int index = obj["fileName"].ToString().LastIndexOf('.');
string fileExt = obj["fileName"].ToString().Substring(index, obj["fileName"].ToString().Length - index);
DataTable list = NPOIExcel.ExcelToTable(stream, fileExt);   // NPOI  读取execl的类库
}

 

Guess you like

Origin www.cnblogs.com/yyl001/p/12121024.html