【实例简介】安卓拍照上传图片,用base64编码传到服务端,服务端用asp.net(c#)编写webservice
【实例截图】
【核心代码】
///
/// 把经过base64编码的字符串保存为文件
///
/// 经base64加码后的字符串
/// 保存文件的路径和文件名
/// 保存文件是否成功
public static bool StringToFile(string base64String, string fileName)
{
//string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase) @"/beapp/" fileName;
System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Create);
System.IO.BinaryWriter bw = new System.IO.BinaryWriter(fs);
if (!string.IsNullOrEmpty(base64String) && File.Exists(fileName))
{
bw.Write(Convert.FromBase64String(base64String));
}
bw.Close();
fs.Close();
return true;
}