コード例 #1
0
        public List <tbl_Fotos_arboles> Llamar_fotos_arboles(String idArbol)
        {
            tbl_Arbol ar = new tbl_Arbol();

            ar.id_arbol = int.Parse(idArbol);
            List <tbl_Fotos_arboles> listaFo = new List <tbl_Fotos_arboles>();
            List <tbl_Fotos_arboles> listaF  = new tbl_Foto_arbolesCAD().Buscar_fotos(ar);

            foreach (var item in listaF)
            {
                String fil    = HttpContext.Current.Server.MapPath(@"~/images/Fotos_Arbol/" + item.foto_arbol);
                bool   existe = File.Exists(fil);
                if (existe)
                {
                    tbl_Fotos_arboles fa         = new tbl_Fotos_arboles();
                    StreamReader      img        = new StreamReader(fil);
                    string            imagenes   = img.ReadLine();
                    String[]          arregloimg = imagenes.Split('~');
                    for (int i = 0; i < arregloimg.Length - 1; i++)
                    {
                        fa.foto_arbol = arregloimg[i];
                        listaFo.Add(fa);
                    }
                }
            }
            return(listaFo);
        }
コード例 #2
0
        public string Insertar_imagen_arbol(string imagen, string nombreCientifico, string nombreComun, int especie)
        {
            tbl_Arbol tblAr = new tbl_Arbol();

            tblAr.nom_cient_arbol  = nombreCientifico;
            tblAr.nom_com_arbol    = nombreComun;
            tblAr.id_especie_arbol = especie;
            tbl_Fotos_arboles tblfA = new tbl_Fotos_arboles();

            tblfA.id_arbol   = new tbl_ArbolCAD().Buscar_id_arbol(tblAr);
            tblfA.foto_arbol = nombreCientifico + ".txt";

            string fil = HttpContext.Current.Server.MapPath(@"~/images/Fotos_Arbol/" + nombreCientifico + ".txt");

            System.IO.StreamWriter file = new StreamWriter(fil);
            file.WriteLine(imagen);
            file.Close();
            Boolean foto    = System.IO.File.Exists(fil);
            string  mensaje = "";

            if (foto)
            {
                mensaje = new tbl_Foto_arbolesCAD().insert_foto_arboles(tblfA);
            }
            StreamReader sr = new StreamReader(fil);

            return(mensaje);
            //return new tbl_Foto_arbolesCAD().insert_foto_arboles(tblfA);
        }