当前位置: 首页>>代码示例>>C#>>正文


C# System.IO.FileInfo.CopyTo方法代码示例

本文整理汇总了C#中System.IO.FileInfo.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.FileInfo.CopyTo方法的具体用法?C# System.IO.FileInfo.CopyTo怎么用?C# System.IO.FileInfo.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.FileInfo的用法示例。


在下文中一共展示了System.IO.FileInfo.CopyTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckCopySlides

        /// <summary>
        /// Check and duplicate the single slide ppt
        /// Copy to the destination
        /// </summary>
        /// <param name="origin"></param>
        /// <param name="target"></param>
        public void CheckCopySlides(string origin, string target)
        {
            POWERPOINT.ApplicationClass ppt = new POWERPOINT.ApplicationClass();
            POWERPOINT.Presentation pres = ppt.Presentations.Open(
                    origin,
                    Microsoft.Office.Core.MsoTriState.msoTrue,
                    Microsoft.Office.Core.MsoTriState.msoTrue,
                    Microsoft.Office.Core.MsoTriState.msoFalse);

            if (pres.Slides.Count == 1)
            {
                pres.SaveAs(
                    target,
                    POWERPOINT.PpSaveAsFileType.ppSaveAsDefault,
                    Microsoft.Office.Core.MsoTriState.msoCTrue);

                pres.Slides[1].Copy();
                pres.Slides.Paste(2);
                pres.Save();
            }
            else
            {
                System.IO.FileInfo file = new System.IO.FileInfo(origin);
                file.CopyTo(target, true);
            }

            pres.Close();
            ppt.Quit();
        }
开发者ID:solunar66,项目名称:AdPlayer,代码行数:35,代码来源:ppt.cs

示例2: SwitchErrorsFile

        private void SwitchErrorsFile(bool onlyValidate)
        {
            try
            {
                rtbDisplay.Clear();

                SPWeb web = Util.RetrieveWeb(txtTargetSite.Text, rtbSiteValidateMessage);
                string pageNotFound = web.Site.WebApplication.FileNotFoundPage;
                if (string.IsNullOrEmpty(pageNotFound))
                {
                    AddToRtbLocal(" Current Error page: (there is currently no Error Page)", StyleType.bodyBlue);
                    return;
                }
                else
                {
                    AddToRtbLocal(" Current Error page: " + pageNotFound + "\r\n", StyleType.bodyBlue);

                    string fileErr = Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles) + @"\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033\" + pageNotFound;
                    System.IO.FileInfo fi = new System.IO.FileInfo(fileErr);
                    if (fi.Exists)
                    {
                        AddToRtbLocal(" Full Path: " + fi.FullName + "\r\n", StyleType.bodyBlue);
                    }
                    else
                        AddToRtbLocal(" Full Path: Can't find full path at: " + fi.FullName + "\r\n", StyleType.bodyBlue);
                }
                AddToRtbLocal("\r\n\r\n", StyleType.bodyBlack);

                if (web != null)
                {
                    System.IO.FileInfo fi = new System.IO.FileInfo(txtNewErrorPage.Text);
                    if (!fi.Exists)
                    {
                        AddToRtbLocal("New File not found '" + fi.FullName + "'", StyleType.bodyBlue);
                        return;
                    }
                    AddToRtbLocal("Copying new error page '" + fi.FullName + "' to Layouts directory. " + Util.V(onlyValidate) + "\r\n", StyleType.bodyBlue);
                    string fileErr = Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles) + @"\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033\" + fi.Name;
                    if (!onlyValidate)
                    {
                        fi.CopyTo(fileErr, true);

                        AddToRtbLocal("Setting WebApplication.FileNotFoundPage property\r\n", StyleType.bodyBlue);
                        Microsoft.SharePoint.Administration.SPWebApplication webApp = web.Site.WebApplication;
                        webApp.FileNotFoundPage = fi.Name;
                        webApp.Update();
                        AddToRtbLocal("\r\nsuccess\r\n", StyleType.bodyBlackBold);
                    }
                }
            }
            catch (Exception ex)
            {
                AddToRtbLocal(ex.Message, StyleType.bodyRed);
            }
        }
开发者ID:iasanders,项目名称:sushi,代码行数:55,代码来源:ActionErrorsFileNotFound.cs

示例3: GetAttchmentInfo

 private void GetAttchmentInfo()
 {
     List<FrameAttachment.DetailUploadFile> DUFList = new FrameAttachment().SelectFilesByGroupGuid2(Request.QueryString["guid"]);
     if (DUFList.Count > 0)
     {
         string FileName = "";
         for (int i = 0; i < DUFList.Count; i++)
         {
             FileName = DUFList[i].FilePath + DUFList[i].FileName;
             string FileType = DUFList[i].FileName.Substring(DUFList[i].FileName.LastIndexOf(".") + 1);
             System.IO.FileInfo fi = new System.IO.FileInfo(Server.MapPath(@FileName));
             fi.CopyTo(Server.MapPath(@"DocList\") + this.ViewState["FileGuid"] + "." + FileType, false);
         }
     }
 }
开发者ID:inspire88,项目名称:TcportGroupOA,代码行数:15,代码来源:RevDoc_Attachment.aspx.cs

示例4: Main

 static void Main(string[] args)
 {
     var binPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Core.Ui.Mvc", "bin");
     var modulesPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Modules.Deploy");
     var dirs = System.IO.Directory.GetDirectories(modulesPath);
     foreach (var dir in dirs)
     {
         var files = System.IO.Directory.GetFiles(dir);
         foreach (var file in files)
         {
             var fileInfo = new System.IO.FileInfo(file);
             System.Console.WriteLine("Copying " + file);
             fileInfo.CopyTo(
                 System.IO.Path.Combine(binPath, fileInfo.Name), true);
         }
     }
 }
开发者ID:JogoShugh,项目名称:ModularAspNetMvc,代码行数:17,代码来源:Program.cs

示例5: ConfirmButton_Click

        private void ConfirmButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.WoWPath.Text))
            {
                MessageBox.Show("请选择您的魔兽路径!如F:\\Wow");
                return;
            }

            if (string.IsNullOrEmpty(this.FontPath.Text))
            {
                MessageBox.Show("请选择您的字体路径!如F:\\xxx\\xxx.ttf");
                return;
            }

            string WoWFontPath = this.WoWPath.Text + "\\Fonts";

            // 如果存在的话,先删除了先把这个删除了
            if (System.IO.Directory.Exists(WoWFontPath))
                System.IO.Directory.Delete(WoWFontPath, true);//适用于里面有子目录,文件的文件夹

            // 创建一个文件夹
            System.IO.Directory.CreateDirectory(WoWFontPath);

            // 复制字体文件好了
            string lastName = System.IO.Path.GetExtension(this.FontPath.Text);
            System.IO.FileInfo fontFile = new System.IO.FileInfo(this.FontPath.Text);
            fontFile.CopyTo(WoWFontPath + "\\ARHei" + lastName);
            fontFile.CopyTo(WoWFontPath + "\\ARIALN" + lastName);
            fontFile.CopyTo(WoWFontPath + "\\ARKai_C" + lastName);
            fontFile.CopyTo(WoWFontPath + "\\ARKai_T" + lastName);
            fontFile.CopyTo(WoWFontPath + "\\FRIZQT__" + lastName);
            fontFile.CopyTo(WoWFontPath + "\\FZBWJW" + lastName);
            fontFile.CopyTo(WoWFontPath + "\\FZXHLJW" + lastName);

            MessageBox.Show("字体复制成功!");
        }
开发者ID:tczzyzymj,项目名称:Prectice,代码行数:36,代码来源:Form1.cs

示例6: GetAttchmentInfo

 private void GetAttchmentInfo(string FileName)
 {
     string FileType = FileName.Substring(FileName.LastIndexOf(".") + 1);
     System.IO.FileInfo fi = new System.IO.FileInfo(Server.MapPath(@FileName));
     fi.CopyTo(Server.MapPath(@"DocList\") + Request.QueryString["guid"] + "." + FileType, false);
 }
开发者ID:inspire88,项目名称:TcportGroupOA,代码行数:6,代码来源:ContractAttBrowser.aspx.cs

示例7: toolStripButton_Save_Click

        private void toolStripButton_Save_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();
            if (DialogResult.OK == sfd.ShowDialog())
            {
                System.IO.FileStream fs_in = System.IO.File.OpenRead(SystemSetup.getInstance().dev_Setup.DataPath + "\\temp");
                System.IO.FileStream fs_out = System.IO.File.OpenWrite(sfd.FileName + ".txt");
                const int frameLen = 3;
                byte[] buf = new byte[frameLen] { 0, 0, 0 };
                string data;
                while (fs_in.Position < fs_in.Length)
                {
                    if (buf[0] == 0xA5)
                    {
                        data = BitConverter.ToInt16(buf, 1).ToString();
                        byte[] databuf = System.Text.ASCIIEncoding.ASCII.GetBytes(data);
                        fs_out.Write(databuf, 0, databuf.Length);
                        fs_out.WriteByte(0x2c);
                        for (int i = 0; i < frameLen; i++)
                        {
                            buf[i] = (byte)fs_in.ReadByte();
                        }
                    }
                    else
                    {
                        for (int i = 0; i < frameLen - 1; i++)
                        {
                            buf[i] = buf[i + 1];
                        }
                        buf[frameLen - 1] = (byte)fs_in.ReadByte();
                    }
                }
                fs_out.Close();
                fs_in.Close();

                System.IO.FileInfo fi = new System.IO.FileInfo(SystemSetup.getInstance().dev_Setup.DataPath+"\\temp");
                fi.CopyTo(sfd.FileName,true);
                //buf1.saveHistory(sfd.FileName);
            }
        }
开发者ID:zskj1225,项目名称:ViberationScope,代码行数:40,代码来源:Form1.cs

示例8: RescanDirectory

        protected void RescanDirectory()
        {
            //Increase timeout
            Server.ScriptTimeout = 600;

            //get list of files
            IEnumerable<FileInfo> filelist = FileUtility.GetSafeFileList(PicturePath, GetExcludedFiles(), GetSortOrder());

            int filelistcount = filelist.Count();
            //If there are any process them
            if (filelistcount > 0)
            {
                //get list from db
                var tc = new ItemController();
                IEnumerable<Item> dblist = tc.GetItems(ModuleId);

                foreach (FileInfo file in filelist)
                {
                    bool isinDB = false;

                    //see if this file is in dm
                    foreach (Item picture in dblist)
                    {
                        if (file.FileName.Contains("thm_") || file.FileName == picture.ItemFileName)
                        {
                            isinDB = true;
                            break;
                        }
                    }
                    if (!isinDB)  //picture is not in db so add it and create thumbnail
                    {
                        Item addPic = new Item();
                        //check for bad filename
                        string goodFileName = RemoveCharactersFromString(file.FileName," '&#<>");
                        if(goodFileName != file.FileName)
                        {
                            //rename the file and use goodfilename instead of file.filename

                            string myPath = Server.MapPath("portals/" + PortalId + "/Gallery/Nano/" + ModuleId + "/");
                            string myOldPath = myPath + file.FileName;
                            string myNewPath = myPath + goodFileName;

                            System.IO.FileInfo f = new System.IO.FileInfo(myOldPath);

                            f.CopyTo(myNewPath);

                            f.Delete();

                        }
                        addPic.ItemFileName = goodFileName;
                        addPic.ItemTitle = goodFileName;
                        addPic.ItemKind = "";
                        addPic.AlbumID = 0;
                        addPic.ItemDescription = "New Picture";
                        addPic.CreatedOnDate = DateTime.Now;
                        addPic.LastModifiedOnDate = DateTime.Now;
                        addPic.LastModifiedByUserId = UserId;
                        addPic.ModuleId = ModuleId;

                        //add to db
                        var tc1 = new ItemController();
                        tc1.CreateItem(addPic);

                        // Get image
                        System.Drawing.Image image = System.Drawing.Image.FromFile(PicturePath + "\\" + goodFileName);

                        float x = image.Width;
                        float y = image.Height;
                        float scale = x / y;
                        int newx = 120;
                        int newy = Convert.ToInt32(120 / scale);
                        if (newy > 120)
                        {
                            newy = 120;
                            newx = Convert.ToInt32(120 * scale);
                        }
                        //create thumbnail
                        System.Drawing.Image thumb = image.GetThumbnailImage(newx, newy, () => false, IntPtr.Zero);
                        thumb.Save(PicturePath + "\\thm_" + goodFileName);
                    }
                }
            }
            //Reload page
            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL());
        }
开发者ID:DLFergrd,项目名称:Shardan_nanoGallery,代码行数:85,代码来源:View.ascx.cs

示例9: Validar_Cambios

        /// <summary>
        /// Validar los cambios y cerrar la ventana
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Validar_Cambios(object sender, RoutedEventArgs e)
        {
            bool valido = true;
            float a;
            int b = 0;

            //Validación de los campos

            if (txtNuevoPrecioProveedor.Text == "" || !float.TryParse(txtNuevoPrecioProveedor.Text, out a))
            {
                txtNuevoPrecioProveedor.Text = "*";
                valido = false;
            }

            if (txtNuevoPrecioUnitario.Text == "" || !float.TryParse(txtNuevoPrecioUnitario.Text, out a))
            {
                txtNuevoPrecioUnitario.Text = "*";
                valido = false;
            }

            if (txtNuevoExistencia.Text == "" || !int.TryParse(txtNuevoExistencia.Text, out b))
            {
                txtNuevoExistencia.Text = "*";
                valido = false;
            }

            //Adquisición de la imagen
            if (valido)
            {
                try
                {
                    var imageFile = new System.IO.FileInfo(rutaFotoProducto);

                    if (imageFile.Exists)
                    {
                        //Conseguir el directorio local
                        var applicationPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                        Console.WriteLine(applicationPath);

                        //Adquirir ruta local de carpeta de Fotografias
                        var dir = new System.IO.DirectoryInfo(System.IO.Path.Combine(applicationPath, "RepProductos"));
                        if (!dir.Exists) dir.Create();

                        rutaFinal = String.Format("{0}\\{1}", dir.FullName, nombreImagen);
                        Console.WriteLine(rutaFinal);

                        //Copiar imagen a la carpeta de Fotografias
                        imageFile.CopyTo(System.IO.Path.Combine(dir.FullName, nombreImagen),true);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error: ");
                    Console.WriteLine(ex.ToString());
                }

                //Registro del producto en la base de datos

                //Conversión a flotante válido de los precios
                float pu = Convert.ToSingle(txtNuevoPrecioUnitario.Text, CultureInfo.InvariantCulture);
                float pv = Convert.ToSingle(txtNuevoPrecioProveedor.Text, CultureInfo.InvariantCulture);

                //Obtención del proveedor
                string consignacionVal = "";
                switch (txtConsignacion.SelectedIndex)
                {
                    case 0: consignacionVal = "La Modistería"; break;
                    case 1:
                        var consignacionBox = proveedorBox;
                        consignacionVal = consignacionBox.Text;
                        break;
                }

                //Actualización de la instancia
                producto.precioUnitario = pu;
                producto.precioProveedor = pv;
                producto.consignacion = consignacionVal;
                producto.existencia = b;
                producto.descripcion = txtNuevoDescripcion.Text;
                producto.foto = rutaFinal;

                //Almacenamiento en la base de datos
                var cfg = new Configuration();
                cfg.Configure();
                var sessions = cfg.BuildSessionFactory();
                var sess = sessions.OpenSession();
                sess.Update(producto);
                sess.Flush();
                sess.Close();

                this.Close();
            }
            else MessageBox.Show("Alguno(s) de los campos son inválidos", "La Modistería | ERROR");
        }
开发者ID:powerponch,项目名称:LaModisteria,代码行数:99,代码来源:CambiarDatosProducto.xaml.cs

示例10: GetAttchmentInfo

 private void GetAttchmentInfo()
 {
     List<FrameAttachment.DetailUploadFile> DUFList = new FrameAttachment().SelectFilesByGroupGuid2(Convert.ToString(ViewState["InfoGuid"]));
     if (DUFList.Count > 0)
     {
         if (DUFList[0].FileName.ToLower().IndexOf("doc") > -1 || DUFList[0].FileName.ToLower().IndexOf("docx") > -1 || DUFList[0].FileName.ToLower().IndexOf("xls") > -1)
         {
             string FileName = "";
             FileName = DUFList[0].FilePath + DUFList[0].FileName;
             string FileType = DUFList[0].FileName.Substring(DUFList[0].FileName.LastIndexOf(".") + 1);
             System.IO.FileInfo fi = new System.IO.FileInfo(Server.MapPath(@FileName));
             fi.CopyTo(Server.MapPath(DUFList[0].FilePath) + this.ViewState["InfoGuid"] + "." + FileType, false);
         }
     }
 }
开发者ID:inspire88,项目名称:TcportGroupOA,代码行数:15,代码来源:Notice_Add.aspx.cs

示例11: btn_Use_Click

        protected void btn_Use_Click(object sender, EventArgs e)
        {
            if (IMGType.SelectedItem.Value == "img0")
            {
                for (int i = 0; i < GridView1.Rows.Count; i++)
                {
                    CheckBox cb = new CheckBox();
                    cb = (CheckBox)GridView1.Rows[i].FindControl("cbSel");
                    if (cb.Checked)
                    {
                        string webPath = Server.MapPath("~/ADIMG/");
                        string upname = GridView1.DataKeys[i].Value.ToString().Substring(GridView1.DataKeys[i].Value.ToString().LastIndexOf("/") + 1).ToUpper();
                        Guid id = System.Guid.NewGuid();
                        string saname = id + upname;
                        System.IO.FileInfo fileinfo = new System.IO.FileInfo(webPath + upname);
                        fileinfo.CopyTo(webPath + saname);
                        CY.HotelBooking.Core.Business.Web_Xml xml = new CY.HotelBooking.Core.Business.Web_Xml();
                        xml.AddElement(webPath, "~/ADIMG/", saname, lab_temp.Text);
                    }

                }
                string tablename = IMGType.SelectedItem.Value;
                dataBind(tablename);
            }
            else if (IMGType.SelectedItem.Value == "img1" || IMGType.SelectedItem.Value == "img2" || IMGType.SelectedItem.Value == "img3")
            {
                if (GridView2.Rows.Count == 1)
                { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('发布列表中已有一张图片');</script>"); }
                else
                {
                    int j = 0;
                    for (int i = 0; i < GridView1.Rows.Count; i++)
                    {

                        CheckBox cb = new CheckBox();
                        cb = (CheckBox)GridView1.Rows[i].FindControl("cbSel");
                        if (cb.Checked)
                        {
                            j++;
                        }

                    }
                    if (j == 1)
                    {
                        for (int i = 0; i < GridView1.Rows.Count; i++)
                        {
                            CheckBox cb = new CheckBox();
                            cb = (CheckBox)GridView1.Rows[i].FindControl("cbSel");
                            if (cb.Checked)
                            {
                                string webPath = Server.MapPath("~/ADIMG/");
                                string upname = GridView1.DataKeys[i].Value.ToString().Substring(GridView1.DataKeys[i].Value.ToString().LastIndexOf("/") + 1).ToUpper();
                                Guid id = System.Guid.NewGuid();
                                string saname = id + upname;
                                System.IO.FileInfo fileinfo = new System.IO.FileInfo(webPath + upname);
                                fileinfo.CopyTo(webPath + saname);
                                CY.HotelBooking.Core.Business.Web_Xml xml = new CY.HotelBooking.Core.Business.Web_Xml();
                                xml.AddElement(webPath, "~/ADIMG/", saname, lab_temp.Text);
                            }

                        }
                    }
                    else if (j > 1)
                    {
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('只能选择一张图片');</script>");
                    }

                    string tablename = IMGType.SelectedItem.Value;
                    dataBind(tablename);
                }
            }
        }
开发者ID:dalinhuang,项目名称:cyhotelbooking,代码行数:72,代码来源:UseIMG.aspx.cs

示例12: GetWordFile

 private void GetWordFile()
 {
     string FileName = "";
     if (at.AttachCount > 0)
     {
         List<FrameAttachment.DetailUploadFile> DUFList = new FrameAttachment().SelectFilesByGroupGuid2(this.ViewState["guid"].ToString());
         FileName =Server.MapPath( DUFList[0].FilePath + DUFList[0].FileName) ;
         if (DUFList.Count > 0)
         {
             string FileName1 = "";
             for (int i = 0; i < DUFList.Count; i++)
             {
                 FileName1 = DUFList[i].FilePath + DUFList[i].FileName;
                 string FileType = DUFList[i].FileName.Substring(DUFList[i].FileName.LastIndexOf(".") + 1);
                 System.IO.FileInfo fi = new System.IO.FileInfo(Server.MapPath(@FileName1));
                 fi.CopyTo(Server.MapPath(@"../RevDoc/DocList\") + this.ViewState["guid"] + "." + FileType, false);
             }
         }
     }
     this.hidFile.Value = FileName;
 }
开发者ID:inspire88,项目名称:TcportGroupOA,代码行数:21,代码来源:SendDoc_Regist_Add.aspx.cs

示例13: Validar_Cambios

        /// <summary>
        /// Validar los cambios y cerrar la ventana
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Validar_Cambios(object sender, RoutedEventArgs e)
        {
            bool valido = true;
            int b = 0;

            //Validación de los campos
            if (txtExistencia.Text == "" || !int.TryParse(txtExistencia.Text, out b))
            {
                txtExistencia.Text = "*";
                valido = false;
            }
            else if (b <= 0)
            {
                txtExistencia.Text = "*";
                valido = false;
            }

            //Adquisición de la imagen
            if (valido)
            {
                try
                {
                    var imageFile = new System.IO.FileInfo(rutaFotoProducto);

                    if (imageFile.Exists)
                    {
                        //Conseguir el directorio local
                        var applicationPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                        Console.WriteLine(applicationPath);

                        //Adquirir ruta local de carpeta de Fotografias
                        var dir = new System.IO.DirectoryInfo(System.IO.Path.Combine(applicationPath, "RepProductos"));
                        if (!dir.Exists) dir.Create();

                        rutaFinal = String.Format("{0}\\{1}", dir.FullName, nombreImagen);
                        Console.WriteLine(rutaFinal);

                        //Copiar imagen a la carpeta de Fotografias
                        imageFile.CopyTo(System.IO.Path.Combine(dir.FullName, nombreImagen), true);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error: ");
                    Console.WriteLine(ex.ToString());
                }

                articulo.nombre = txtNombre.Text;
                articulo.existencia = txtExistencia.Text;
                articulo.descripcion = txtDescripcion.Text;
                articulo.imagen = rutaFinal;

                //Almacenamiento en la base de datos
                var cfg = new Configuration();
                cfg.Configure();
                var sessions = cfg.BuildSessionFactory();
                var sess = sessions.OpenSession();
                sess.Update(articulo);
                sess.Flush();
                sess.Close();

                this.Close();
            }
            else MessageBox.Show("Alguno(s) de los campos son inválidos", "La Modistería | ERROR");
        }
开发者ID:powerponch,项目名称:LaModisteria,代码行数:70,代码来源:CambiarDatosArticulo.xaml.cs

示例14: CopyInstaller

 /// <summary>
 /// Copy the installer.
 /// </summary>
 public void CopyInstaller()
 {
     System.IO.FileInfo nfi = new System.IO.FileInfo(Properties.Settings.Default.InstallerNetworkPath);
       nfi.CopyTo(Properties.Settings.Default.EngineeringDir + @"\InstallRedBrick.exe", true);
 }
开发者ID:kcjuntunen,项目名称:Redbrick-Addin,代码行数:8,代码来源:Redbrick.cs

示例15: Registrar_Articulo

        /// <summary>
        /// Valida los datos ingresados y registra un nuevo producto
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Registrar_Articulo(object sender, RoutedEventArgs e)
        {
            bool valido = true;
            int b = 0;

            //Validación de los campos
            if (txtNombre.Text == "")
            {
                txtNombre.Text = "*";
                valido = false;
            }

            if (txtDescripcion.Text == "")
            {
                txtDescripcion.Text = "*";
                valido = false;
            }

            if (txtExistencia.Text == "" || !int.TryParse(txtExistencia.Text, out b))
            {
                txtExistencia.Text = "*";
                valido = false;
            }

            //Obtención del proveedor
            switch (comboTipo.SelectedIndex)
            {
                case 0: tipoArticulo = "Maquinaria"; break;
                case 1: tipoArticulo = "Herramienta"; break;
                case 2: tipoArticulo = "Materia Prima"; break;
            }

            //Adquisición de la imagen
            if (valido)
            {
                try
                {
                    var imageFile = new System.IO.FileInfo(rutaFotoProducto);

                    if (imageFile.Exists)
                    {
                        //Conseguir el directorio local
                        var applicationPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                        Console.WriteLine(applicationPath);

                        //Adquirir ruta local de carpeta de Fotografias
                        var dir = new System.IO.DirectoryInfo(System.IO.Path.Combine(applicationPath, "RepProductos"));
                        if (!dir.Exists) dir.Create();

                        rutaFinal = String.Format("{0}\\{1}", dir.FullName, nombreImagen);
                        Console.WriteLine(rutaFinal);

                        //Copiar imagen a la carpeta de Fotografias
                        imageFile.CopyTo(System.IO.Path.Combine(dir.FullName, nombreImagen), true);
                    }
                }
                catch (Exception) { }

                //Creación del nuevo artículo
                Articulo nuevoArticulo = new Articulo
                {
                    tipo = tipoArticulo,
                    nombre = txtNombre.Text,
                    descripcion = txtDescripcion.Text,
                    existencia = txtExistencia.Text,
                    imagen = rutaFinal
                };

                //Almacenamiento en la base de datos
                var cfg = new Configuration();
                cfg.Configure();
                var sessions = cfg.BuildSessionFactory();
                var sess = sessions.OpenSession();
                sess.Save(nuevoArticulo);
                sess.Flush();
                sess.Close();

                ResetCampos();
                CargarProductos();
            }
            else MessageBox.Show("Alguno(s) de los campos son inválidos", "La Modistería | ERROR");
        }
开发者ID:powerponch,项目名称:LaModisteria,代码行数:87,代码来源:ConsultarTallerControl.xaml.cs


注:本文中的System.IO.FileInfo.CopyTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。