简体   繁体   English

将图像的字节数组保存在文件夹C#中

[英]Save byte array of image in a folder c#

I am converting image name to byte array and i want to save that byte array in a folder here is my code to convert byte array 我将图像名称转换为字节数组,我想将该字节数组保存在文件夹中,这是我的代码,用于转换字节数组

 byte[] imgArray = obj.Image.ToByteArray();

where obj.image=image(1).jpg. 其中obj.image = image(1).jpg。 which is of string type. 这是字符串类型。

and I want to save it in my project folder "Images" so how can i do it after converting that image file to byte array. 并且我想将其保存在我的项目文件夹“ Images”中,以便在将图像文件转换为字节数组后如何做。 please give me some idea to do that 请给我一些想法

here is my project folder where i want to save the file. 这是我要保存文件的项目文件夹。 D:\\Gaurav\\VerveLogicTfs\\LogoProject\\ProfilePic d:\\拉夫\\ VerveLogicTfs \\ LogoProject \\ ProfilePic

Try this. 尝试这个。

string filePath = "~/ProfilePic/" + obj.image.ToString();
File.WriteAllBytes(Server.MapPath(filePath), imgArray);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM