-1

我已经使用转换文件Convert.ToBase64String并保存到数据库。但是我在再次检索文件时遇到了问题。

请帮忙...

_copyLocation = ApplicationDeployment.CurrentDeployment.DataDirectory + "\\" +
                DateTime.Now.ToString("dd_MM_yyyy_HH_mm_ss") + ".sdf";


File.Copy(ApplicationDeployment.CurrentDeployment.DataDirectory + "\\" + 
          "Data.sdf", _copyLocation);

byte[] byteArray = System.IO.File.ReadAllBytes(_copyLocation);
MemoryStream stream = new MemoryStream(byteArray);
stream.Read(byteArray, 0, (int)stream.Length);

保存到数据库为: Convert.ToBase64String(byteArray);

4

2 回答 2

0
Convert.FromBase64String(File.ReadAllText(_copyLocation))
于 2013-04-27T14:09:29.313 回答
0

我使用以下转换..工作正常..:

  File.WriteAllBytes("1.sdf", Convert.FromBase64String(System.Text.Encoding.ASCII.GetString((byte[])ds.Tables[0].Rows[0][3])));
于 2013-04-27T14:19:09.980 回答