Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how can i read an array of System.Drawing.Image with a stream
this code doen't work:
C#
int i=0;
    Image [] image = new Image[100];
        while (reader.Read())
    {
        string filePath = (string)reader["Path"];
        byte[] transactionContext = (byte[])reader["TransactionContext"];
        SqlFileStream sqlFileStream = new SqlFileStream(filePath, transactionContext, FileAccess.Read);
        byte[] data = new byte[Convert.ToInt32(sqlFileStream.Length)];
        sqlFileStream2.Read(data, 0, Convert.ToInt32(sqlFileStream.Length));
        image[i] = System.Drawing.Image.FromStream(sqlFileStream, true, true);
        //sqlFileStream.Close();
        i++;

    }
Posted
Comments
Sergey Alexandrovich Kryukov 15-Sep-13 23:34pm    
Did you append the same stream/file with several images? Why?
(Anyway, even if you did such weird string, you should just repeat FromStream several times.)
I hope you didn't, but then you do just the same as with one image. Actually, what's the problem?
—SA
Reza Oruji 15-Sep-13 23:42pm    
i read images from db to an array of images but when i show the image, they all are same.
Sergey Alexandrovich Kryukov 16-Sep-13 0:13am    
You need to show more comprehensive code sample.
At least one thing is totally wrong: array with 100 elements. How do you know there are 100. Use, say, some list.
—SA
Reza Oruji 17-Sep-13 0:57am    
thanks,so a list of Stream and a a list of Image. how about this ?
Sergey Alexandrovich Kryukov 17-Sep-13 1:57am    
If so, who would it differ from one stream and one image?
—SA

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900