Click here to Skip to main content
15,887,936 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need to transfer data from treeView1 control to some .txt file.
I am using streamwriter for creating file from System::IO..
This is how treeView looks:
http://postimg.org/image/pwnc4s01v/[^]

And here is code , which won't work, i tried to transfer from Private only to txt first then i would copy code for the rest..

C++
//code sample
			 String^ s1;
			 String^ s2;
			 String^ s3;
			 int n;
			 n = treeView1->TopNode->Nodes[0]->Nodes->Count;
			 int m;
			 m = treeView1->TopNode->Nodes[1]->Nodes->Count;
			 int z;
			 z = treeView1->TopNode->Nodes[2]->Nodes->Count;
			 //upisujemo
			 StreamWriter^ sw = gcnew StreamWriter("view.txt");
			 sw->WriteLine("class " + treeView1->TopNode->Text + " {");
			 for(int i  = 0; i<n; i++)
			 {
				 sw->WriteLine(treeView1->TopNode->Nodes[0]->Text);
				 sw->WriteLine(treeView1->Nodes[1]->Nodes[i]->Text);	
			 }
			 
			 sw->Flush();
			 sw->Close();
			 delete sw;	
Posted
Comments
Matthew Faithfull 22-Apr-13 8:53am    
What doesn't work about this? Does it compile? Does it run? Does it produce a file? Is the contents of the file what you want?
[no name] 22-Apr-13 10:43am    
in view.txt shows:

class class1{
Private:


Only that..?
KarstenK 23-Apr-13 3:11am    
I mean that path:

StreamWriter^ sw = gcnew StreamWriter("view.txt");

I guess you missed some basic learning in programming. Do your homeworks properly ;-)
[no name] 23-Apr-13 3:47am    
The path is working beleve me. It's create view.txt file i project solution folder, where are files of a project..

1 solution

you should better use a complete path for that.
 
Share this answer
 
Comments
[no name] 22-Apr-13 10:43am    
I do not understand, which path, path of file?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900