Exemple #1
0
 /// <summary>
 /// Devuelve todos los archivos Word que se encuentran
 /// en la carpeta seleccionada
 /// </summary>
 /// <param name="path"></param>
 public async Task StartTaskLoadFilesFromFolder(CancellationToken ct)
 {
     try
     {
         var ext = new List <string> {
             ".docx", ".doc"
         };
         var           myFiles = Directory.GetFiles(selectedPath, "*.*", SearchOption.AllDirectories).Where(s => ext.Contains(Path.GetExtension(s)));
         List <string> Files   = myFiles.OfType <string>().ToList();
         foreach (string file in Files)
         {
             document = new WordDocumentFile(file);
             var date = File.GetLastWriteTime(file).ToString("dd/MM/yyyy");
             SetFileInfo(document.DocumentName, descriptionFirstElement, document.DocumentCharactersCount, date);
             if (ct.IsCancellationRequested)
             {
                 break;
             }
         }
         progressBarForm.CancelTask = true;
         progressBarForm.Close();
     }
     catch (Exception ex)
     {
         progressBarForm.CancelTask = true;
         progressBarForm.Close();
         MessageBox.Show(ex.Message);
     }
 }
Exemple #2
0
        private void buttonAddWork_Click(object sender, EventArgs e)
        {
            openFileDialog1.Filter = "DOCX (*.docx)| *.docx";
            DialogResult result = openFileDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {
                document = new WordDocumentFile(openFileDialog1.FileName);
                var date = File.GetLastWriteTime(openFileDialog1.FileName).ToString("dd/MM/yyyy");
                SetFileInfo(document.DocumentName, descriptionFirstElement, document.DocumentCharactersCount, date);
            }
        }
Exemple #3
0
        /// <summary>
        /// Devuelve todos los archivos Word que se encuentran
        /// en la carpeta seleccionada
        /// </summary>
        /// <param name="path"></param>
        public void LoadFilesFromFolder()
        {
            var ext = new List <string> {
                ".docx", ".doc"
            };
            var myFiles = Directory.GetFiles(selectedPath, "*.*", SearchOption.AllDirectories).Where(s => ext.Contains(Path.GetExtension(s)));
            //var myFiles = Directory.GetFiles(selectedPath, "*.*", SearchOption.AllDirectories).Where(file => new string[] { ".docx", ".doc" }.Contains(Path.GetExtension(file)));
            List <string> Files = myFiles.OfType <string>().ToList();

            //var myFiles = Directory.GetFiles(path);
            foreach (string file in Files)
            {
                document = new WordDocumentFile(file);
                var date = File.GetLastWriteTime(file).ToString("dd/MM/yyyy");
                //SetFileInfo(document.DocumentName, "Ansprüche EN-DE", document.DocumentCharactersCount, date);
                SetFileInfo(document.DocumentName, descriptionFirstElement, document.DocumentCharactersCount, date);
            }
            progressBarForm.ShowProgressBar = false;
            progressBarForm.UpdateProgressBar();
        }
Exemple #4
0
        private async Task StartTaskLoadFileFromWordAddMenu(string[] fileNames, CancellationToken ct)
        {
            try
            {
                foreach (string fileName in fileNames)
                {
                    //document = new WordDocumentFile(openFileDialog1.FileName);
                    document = new WordDocumentFile(fileName);
                    //var date = File.GetLastWriteTime(openFileDialog1.FileName).ToString("dd/MM/yyyy");
                    var date = File.GetLastWriteTime(fileName).ToString("dd/MM/yyyy");
                    SetFileInfo(document.DocumentName, descriptionFirstElement, document.DocumentCharactersCount, date);
                }

                progressBarForm.CancelTask = true;
                progressBarForm.Close();
            }
            catch (Exception ex)
            {
                progressBarForm.CancelTask = true;
                progressBarForm.Close();
                MessageBox.Show(ex.Message);
            }
        }