New Visual C# .NET project for a newb

hawkmcdowell85

Newcomer
Joined
Jun 15, 2011
Messages
2
Hello, I have some limited background in C++ and Java, though I haven't programmed in years. I'm wanting to begin programming through learning C#. I have a project plan in sight to help me learn along the way using Windows Forms and C#. I was looking for guidance here in breaking up the component pieces of what needs to be logically done along with certain things I need to research for best practices in the design.

Here is a rundown of the idea:

There is a folder on a PC (\..\Mail\Messages) that contains several XML files that are placed there by an existing application. I'd like to determine the location of the folder across different environments as it could be on any drive letter (C:\...D:\... etc..). I'd want to parse the XML files and then display their data in a Windows form with the option to change data through the GUI, delete the XML, or move the XML to a different folder (\..\Mail\Process).

The XML also has base64 encoded plain-text or HTML as an attribute that would need to be converted to ASCII to be readable in the GUI. I'd want the option to edit a certain value for only one XML or the same value for all XML, since each XML has the same skeleton with attributes but just different values. Since the data being changed may be an email address, I'd like to be able to confirm if the user enters a new address or edits an existing one that it is valid. This application doesn't need to do SMTP delivery. I may also want to build a subfolder of Mail\Messages\backup to backup the working XML files so that the user can revert any changes after they have saved them in the GUI. There could be just a few XMLs or up to hundreds in this Mail\Messages folder.

I'm using Visual Studio 2010 (C#) and Windows Forms. I'm doing some research to see how I should lay out these component parts along with some initial learning of the C# language and concepts.

If you can offer any advice for direction or references for different pieces I will need to consider to begin coding this, it would be much appreciated!

Thanks!

Jason
 
I've had successful testing using StreamReader, XmlTextReader, and XmlDocument and locating nodes via the Parent/Child relationship of node traversal. The XML files aren't very well formed and I have no control over that so this method works well with a given XML structure that is unlikely to change any time soon (outside of my control).

Code:
      //Retrieve the XML and convert to stream
 
      StreamReader sr = new StreamReader(@"C:\App\Mail\NoRetry\507987487.xml");
      
      //Read the XML
   
      XmlTextReader xr = new XmlTextReader(sr);
   
      //Create the XML
  
     XmlDocument MessageNewXml = new XmlDocument();
 
      MessageNewXml.Load(xr);
 
      XmlNode MessageNode = MessageNewXml.FirstChild;       
  
      //Obtain the email address
  
      DataTextbox.Text = MessageNode.FirstChild.FirstChild.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.FirstChild.FirstChild.FirstChild.InnerText;

[code]

The next piece I am researching is how I will want to iterate through the NoRetry folder to read in each XML, such as Directory.GetFiles(MailDir, "*.xml"). I presume there is some way to keep track of each XML by using array(s) or something similar. Once they are read in, I want to display most pieces of the XML in formated grid view (such as via the data table grid view). The user should be able to manipulate data within the GUI and I need to propagate the changes back to the XML changed (value change, delete entire XML, move the XML to another folder).

I'm not currently sure how to manage all the XML files with the future display and data manipulation for each. Any direction in the mean time while I research this would be gladly accepted
 
Back
Top