tags:

views:

134

answers:

1

I have this Xml file that i browse from my HDD into my C# program. Now the nodes of this Xml doc get displayed in a tree view in my winform. All my logic is in the winform right now. There are three methods:

  1. To load the Xml doc in memory.
  2. Add nodes to tree which is called by the previous method in point 1.
  3. And event that works when i click on any node to find its attributes.

Rest, i have various buttons like browse, expand tree, clear. all are in the winform. My browse button click event is also in the winform class which is obvious.

Now what i have to do it i have to make a separate class for business logic that includes the method in point 1 and point 2. Rest remains in the winform class. this new class is in the same project. Now the project has two classes - 1 is winforms and the other is that i made to store my business logic so as to keeping frontend class free from business logic.

I cannot do that by making use of objects but i have to make use of giving file path in the class that has the logic. so that, that class knows the file path. Do you have any idea how can i do it?

Please tell me the syntax as i am a newbie.

+1  A: 

I believe you're looking for the OpenFileDialog component, if you want the user to be able to specify the path of the file.

If not, then just pass the path in as a parameter in your business class logic:

public class MyBusinessLogic {
   public MyBusinessLogic(String filePath) {
      this.FilePath = filePath;
   }
   public String FilePath { get; private set; }
   public void Process() {
      // whatever you do here
   }
}
Daniel Schaffer
How do i make a refernce to it in my front end class?? I mean what shall i write in my front end class to be able to call the methods of business logic class? As my OpenFileDialog component and browse button both are in front end class
I am calling my load xml doc method from the Browse button click event.