.net/wpf 文件流转换

//文件流转换
private string IOSwitchPath_G(byte[][] byte_picture)
{
try
{

            //获取基目录,它由程序集冲突解决程序用来探测程序集。
            string strSystemPath = System.AppDomain.CurrentDomain.BaseDirectory + "_08Server_Img\\Simages\\";
            if (!Directory.Exists(strSystemPath)) Directory.CreateDirectory(strSystemPath);

            string strPicturePath = string.Empty;

            //遍历二进制的数组的数组
            for (int i = 0; i < byte_picture.Length; i++)
            {
                //拼接日期
                string strGuid = Guid.NewGuid().ToString();
                string strRiQiWenJian = strGuid + ".png";

                //拼接路径
                strSystemPath = strSystemPath + strRiQiWenJian;
                FileInfo fi = new System.IO.FileInfo(strSystemPath);
                FileStream fs;
                fs = fi.OpenWrite();
                //将字节块写入文件流。(数组,开始字节索引,长度)
                fs.Write(byte_picture[i], 0, byte_picture[i].Length);
                //关闭当前流并释放与之关联的所有资源
                fs.Close();

                strPicturePath = strRiQiWenJian;
            }

            return strPicturePath;
        }
        catch
        {
            return null;
        }
    }
发布了115 篇原创文章 · 获赞 36 · 访问量 9897

猜你喜欢

转载自blog.csdn.net/weixin_44548307/article/details/102908951
今日推荐