예제 #1
0
        private void copiarserver(string _origen)
        {
            string _ruta_Server = Basico._ruta_catalogo("OU") + "\\" + txtvirtual.Text.Trim();

            try
            {
                DirectoryInfo sourceDir      = new DirectoryInfo(@_origen);
                DirectoryInfo destinationDir = new DirectoryInfo(@_ruta_Server);

                CopyDirectory(sourceDir, destinationDir);
            }
            catch
            {
                throw;
            }
        }
예제 #2
0
        private void crear_pdf(string path_destino)
        {
            try
            {
                //Basico.ejecuta_pdf(@"D:\David\AQUARELLA SQL\Sistema\Vb C# 2013\ELECTRONICO_CARVAJAL\ELECTRONICO\Sistema\www.aquarella.com.pe\CatalogoVirtual\bin\Debug\catalogo-peru\pdf\catalogo.html", @"D:\David\AQUARELLA SQL\Sistema\Vb C# 2013\ELECTRONICO_CARVAJAL\ELECTRONICO\Sistema\www.aquarella.com.pe\CatalogoVirtual\bin\Debug\catalogo-peru\pdf\catalogo.pdf");

                string   ruta_foto = path_destino + "\\pages";
                string[] _foto     = null;
                _foto = Directory.GetFiles(@ruta_foto, "*.jpg");


                //DirectoryInfo dir = new DirectoryInfo(@ruta_foto);
                //FileInfo[] files = dir.GetFiles("*.jpg").OrderBy(p => p.CreationTime).ToArray();

                //string[] _fotoorder=Directory.GetFiles(@ruta_foto, "*.jpg").Select(a => new
                //{
                //    FileName = System.IO.Path.GetFileName(a),
                //}).OrderByDescending(a => a.FileName);

                //var sorted = Directory.GetFiles(".").OrderBy(f => f);

                if (_foto.Length > 0)
                {
                    string path_destino_pdf     = path_destino + "\\pdf";
                    string file_detino_html_pdf = path_destino_pdf + "\\catalogo.html";
                    string file_destino_pdf     = path_destino_pdf + "\\catalogo.pdf";
                    string readContentsprincipal;
                    using (StreamReader streamReader = new StreamReader(file_detino_html_pdf, Encoding.UTF8))
                    {
                        readContentsprincipal = streamReader.ReadToEnd();
                    }


                    string _img_html = "";

                    for (Int32 i = 0; i < _foto.Length; ++i)
                    {
                        string   fileorigen  = _foto[i].ToString();
                        FileInfo fi_name     = new FileInfo(fileorigen);
                        string   num         = (i + 1).ToString() + ".jpg";
                        string   filedestino = ruta_foto + "\\" + num;//fi_name.Name;
                        _img_html += "<img src='file:///" + filedestino + "' width='573' height='780' border='2' />";

                        //break;
                    }
                    readContentsprincipal = readContentsprincipal.Replace("xxxx", _img_html);

                    using (var fileStream = File.Create(@file_detino_html_pdf))
                    {
                        var texto = new UTF8Encoding(true).GetBytes(readContentsprincipal);
                        fileStream.Write(texto, 0, texto.Length);
                        fileStream.Flush();
                    }
                    Basico.ejecuta_pdf(@file_detino_html_pdf, @file_destino_pdf);
                }
            }
            catch
            {
                throw;
            }
        }