Bonjour : ),

Je voudrais un peut d'aide au niveau d'une fonction que j'ai crée, permettant de convertir des images, situé dans un dossier, en byte array, ceci dans le but de le transmettre à une application flex, le reconvertissant en image. (en effet les types d'images flex et c# sont différentes).

Voici ma fonction, dont je ne sais où est l'erreur, en faites je récupére le chemin de l'image et non son contenu...

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System;
using System.IO;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Drawing;
using System.Windows.Forms;
 
/// <summary>
/// Description résumée de Class1
/// </summary>
/// 
 
namespace External
{
    public class BiblioPlan
    {
        private ArrayList listeBiblio;
        private byte[] MesBytes;
        private Image img;
        private ArrayList listeImage;
        private String path;
 
        //this function will have a parameter who will be the path of the application
        public ArrayList getBiblio()
        {
            listeBiblio = new ArrayList();
            listeImage = new ArrayList();
            path = "";
            Console.Write(System.IO.Path.GetDirectoryName(Application.ExecutablePath));
 
            String[] fichiers = Directory.GetFiles("C:/blabla/Flex3/src/assets/image");
            for (int i = 0 ; i < fichiers.Length ; i++)
            {
                // écrire en console les noms des fichiers
                 Console.Out.WriteLine(fichiers[i]);
 
                // read un fichier et le transformer en byte
                 System.IO.FileInfo MonFichier = new System.IO.FileInfo(fichiers[0]);
                 System.IO.FileStream MonFileStream = MonFichier.OpenRead();
                 listeBiblio.Add(MonFileStream.Name);
                 byte[] TableauDeBytes = new byte[MonFileStream.Length];
                 MonFileStream.Read(TableauDeBytes, 0, (int)MonFileStream.Length);
                 MonFileStream.Close();
                 MesBytes = TableauDeBytes;
                // créer l'image associée au buffer
                 if (TableauDeBytes.Length > 0)
                 {
                     img = StreamToImage(TableauDeBytes);
 
                     // créer liste image
                     listeBiblio.Add(fichiers[i]);
                     listeImage.Add(img);
                     MesBytes.Initialize();
                 }
            }
            return listeImage;
        }
 
        public static Image StreamToImage(byte[] buff)
        {
            // créer image associée au buffer
            MemoryStream memStream = new MemoryStream();
            Stream ms = new MemoryStream(buff);
            Image img = Image.FromStream(ms);
            return img;
        }
 
 
    }// end of class
}// end of package
merci de vote aide