文件转化成XML
public partial class WebForm1 : System.Web.UI.Page
{
static string markType = ""; //图片类型
static int markSize = 0; //图片长度
static byte[] markContent; //图片数据
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string geifile = this.markname.Text;//获取数据
//获取上传文件流
string getfile = this.FileUpload1.PostedFile.FileName;
//获取上传文件流
markContent = new byte[this.FileUpload1.PostedFile.ContentLength];
Stream filestream = this.FileUpload1.PostedFile.InputStream;
//读入数据
filestream.Read(markContent, 0, this.FileUpload1.PostedFile.ContentLength);
markType = this.FileUpload1.PostedFile.ContentType;
markSize = this.FileUpload1.PostedFile.ContentLength;
GetXMLfile(markType, markSize, markContent);
}
public string GetXMLfile(string FileType, int FileSize, byte[] FileContent)
{
string Callsxml = string.Empty;
Callsxml += "<?xml version="1.0" encoding="UTF-8"?>";
Callsxml += "<File>";
Callsxml += "<FileType>" + FileType + "</FileType>";
Callsxml += "<FileSize>" + FileSize + "</FileSize>";
Callsxml += "<FileContent>" + FileContent + "</FileContent>";
Callsxml += "</File>";
return null;
}
}
为什么我点上传文件<FileContent>System.Byte[]</FileContent>这个参数得不得
[解决办法]
System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(Convert.FromBase64String(pic));
就可以读取了
http://dotnet.aspx.cc/article/ebd43e74-1bde-43aa-deaf-211fa24a7bc2/read.aspx