Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.IO;
- using Microsoft.WindowsAPICodePack.Dialogs;
- using System.Xml;
- using System.Xml.Serialization;
- using ps9 = PlanSwift9;
- namespace WindowsFormsApplication1
- {
- public partial class mAllInOne : Form
- {
- public mAllInOne()
- {
- InitializeComponent();
- var test =
- }
- class TGlobal
- {
- public static pswift.IPlanSwift ps;
- public static List<string> tlst;
- }
- private void mBrowse_Click(object sender, EventArgs e)
- {
- int size = -1;
- CommonOpenFileDialog openFileDialog1 = new CommonOpenFileDialog();
- //Show the Dialog and get Result
- openFileDialog1.IsFolderPicker = true;
- CommonFileDialogResult result = openFileDialog1.ShowDialog();
- if (result == CommonFileDialogResult.Ok) //Test Result.
- {
- string file = openFileDialog1.FileName;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.IO;
- using Microsoft.WindowsAPICodePack.Dialogs;
- using System.Xml;
- using System.Xml.Serialization;
- using ps9 = PlanSwift9;
- namespace WindowsFormsApplication1
- {
- public partial class mAllInOne : Form
- {
- public mAllInOne()
- {
- InitializeComponent();
- var test =
- }
- class TGlobal
- {
- public static pswift.IPlanSwift ps;
- public static List<string> tlst;
- }
- private void mBrowse_Click(object sender, EventArgs e)
- {
- int size = -1;
- CommonOpenFileDialog openFileDialog1 = new CommonOpenFileDialog();
- //Show the Dialog and get Result
- openFileDialog1.IsFolderPicker = true;
- CommonFileDialogResult result = openFileDialog1.ShowDialog();
- if (result == CommonFileDialogResult.Ok) //Test Result.
- {
- string file = openFileDialog1.FileName;
- try
- {
- //Data Structure to hold names of Folders to be examined for files
- Stack<string> dirs = new Stack<string>(20);
- if (Directory.Exists(file))
- {
- // throw new ArgumentException();
- }
- dirs.Push(file);
- while (dirs.Count > 0)
- {
- string currentDir = dirs.Pop();
- string[] subDirs;
- try
- {
- subDirs = Directory.GetDirectories(currentDir);
- }
- // An UnauthorizedAccessException exception will be thrown if we do not have
- // discovery permission on a folder or file. It may or may not be acceptable
- // to ignore the exception and continue enumerating the remaining files and
- // folders. It is also possible (but unlikely) that a DirectoryNotFound exception
- // will be raised. This will happen if currentDir has been deleted by
- // another application or thread after our call to Directory.Exists. The
- // choice of which exceptions to catch depends entirely on the specific task
- // you are intending to perform and also on how much you know with certainty
- // about the systems on which this code will run.
- catch (UnauthorizedAccessException er)
- {
- MessageBox.Show((er.Message), "ERROR", MessageBoxButtons.OK,
- MessageBoxIcon.Error,
- MessageBoxDefaultButton.Button1);
- continue;
- }
- catch (DirectoryNotFoundException er)
- {
- MessageBox.Show((er.Message), "ERROR", MessageBoxButtons.OK,
- MessageBoxIcon.Error,
- MessageBoxDefaultButton.Button1);
- continue;
- }
- string[] Files = null;
- try
- {
- Files = Directory.GetFiles(currentDir,"Data.xml");
- }
- catch (UnauthorizedAccessException er)
- {
- MessageBox.Show((er.Message), "ERROR", MessageBoxButtons.OK,
- MessageBoxIcon.Error,
- MessageBoxDefaultButton.Button1);
- continue;
- }
- catch (DirectoryNotFoundException er)
- {
- MessageBox.Show((er.Message), "ERROR", MessageBoxButtons.OK,
- MessageBoxIcon.Error,
- MessageBoxDefaultButton.Button1);
- continue;
- }
- // Perform the required action on each file here.
- // Modify this block to perform your required task.
- foreach (string fileXML in Files)
- {
- try
- {
- //Here is where I read the XML Files
- XmlDocument doc = new XmlDocument();
- TGlobal.ps = new ps9.PlanSwift();
- string jobPath = TGlobal.ps.Root().FullPath() + file;
- ps9.IItem takeoff = TGlobal.ps.GetItem(jobPath);
- doc.Load(fileXML);
- string elem = doc.DocumentElement.InnerText;
- MessageBox.Show(elem);
- mItemList.Items.Add(elem);
- }
- catch (FileNotFoundException er)
- {
- MessageBox.Show((er.Message), "ERROR", MessageBoxButtons.OK,
- MessageBoxIcon.Error,
- MessageBoxDefaultButton.Button1);
- continue;
- }
- }
- //Push subdirectories onto the stack for Traversal.
- //This could also be done before handing the files.
- foreach (string str in subDirs)
- dirs.Push(str);
- }
- }
- catch (IOException)
- {
- }
- }
- }
- private void panel1_Paint(object sender, PaintEventArgs e)
- {
- }
- private void panel2_Paint(object sender, PaintEventArgs e)
- {
- }
- private void mBrowse2_Click(object sender, EventArgs e)
- {
- }
- private void progressBar3_Click(object sender, EventArgs e)
- {
- }
- private void mAllInOne_Load(object sender, EventArgs e)
- {
- }
- private void button2_Click(object sender, EventArgs e)
- {
- }
- }
- }
- catch (IOException)
- {
- }
- }
- }
- private void panel1_Paint(object sender, PaintEventArgs e)
- {
- }
- private void panel2_Paint(object sender, PaintEventArgs e)
- {
- }
- private void mBrowse2_Click(object sender, EventArgs e)
- {
- }
- private void progressBar3_Click(object sender, EventArgs e)
- {
- }
- private void mAllInOne_Load(object sender, EventArgs e)
- {
- }
- private void button2_Click(object sender, EventArgs e)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement