在服务器端编写csv文件,并通过WCF RIA服务将其发送到silverlight客户端
我已经在服务器端创建了csv文件。现在我想把它发送给我的silverlight客户端 通过WCF RIA服务。我创建了以下内容:在服务器端编写csv文件,并通过WCF RIA服务将其发送到silverlight客户端,silverlight,file,wcf-ria-services,Silverlight,File,Wcf Ria Services,我已经在服务器端创建了csv文件。现在我想把它发送给我的silverlight客户端 通过WCF RIA服务。我创建了以下内容: public byte[] GetMyCSV() { string file = @"c:\test.csv"; using (StreamWriter sw = new StreamWriter(file, true, Encoding.GetEncoding(932))) { //write csv file content ...
public byte[] GetMyCSV()
{
string file = @"c:\test.csv";
using (StreamWriter sw = new StreamWriter(file, true, Encoding.GetEncoding(932)))
{
//write csv file content
...
}
???
}
我的服务应该发送字节数组吗?If-then如何从StreamWriter获取字节数组?首先,If类用于写入文件。只要我理解你的问题,你就想从文件中读出来
从文件中读取所有字节的最简单方法是使用类和方法
另一种方法是使用类,从文件中读取字节块,并定义额外的编码进行读取。首先,类if用于写入文件。只要我理解你的问题,你就想从文件中读出来
从文件中读取所有字节的最简单方法是使用类和方法
另一种方法是使用类,从文件中读取字节块,并定义用于读取的其他编码
public byte[] GetMyCSV(){
string file = @"c:\test.csv";
bytes[] fileBytes;
using (var fileStream = File.OpenRead(file)) {
fileBytes = fileStream.ReadAllBytes();
}
return fileBytes;
}