So I'm making a custom text editor for web development. I am planning to unclude the use of projects to group common files together, however im having a hard time going about it.

I have a form that when opened, will give the user options to create a new project such as title, type (text, html, php etc), location to save and such. When the project is created I can get the folder to save, and a project file (contains information about the project just create) is created in the new folder.

Im having a hard time using the tree viewer to display the title of the new project, which would then display new files as child nodes.

I am also struggling to open the project file (.proj -> mad it up, its just a text file) to open with my application and open all of the relevent files included in the project in the editor.

... Whoah thats more than I expected to write... All comments will be greatley appreciated in advanced!

Recommended Answers

All 7 Replies

I am IT Engineer Want to work wit web programming

Hi,

Can you be more specific were exactly you're struggling?

I've just looked into TreeViewer and I found it straightforward, here is what I've tried:

string[] files = new []{"file 1", "file 2"}; // files array that needs to be read from a file

TreeNode projectRootNode = treeView1.Nodes.Add("project_name"); // create root node of the project

// filling the project root node branch with the files
for (int i = 0; i < files.Length; i++)
    projectRootNode.Nodes.Add(files[i]);

You didn't say much about the (.proj) file although your thread title is all about it. How you manage that file? What type is it (e.g. xml)?

Hey Diamons,

Yeah sorry I totally forgot to mention it! I have however fixed the treeView errors.

I have created a .proj file that contains the files within the specific project. At the moment, I have .proj's opening with Notepad++. However, whenever I choose to open them with my application nothing happens.

How can I get it so when I open it with the application, the app reads the .proj file, finds the relevent files that go with it, and display them using the tab pages function?

Good news!
hmmm, let's see.. how do you open the file in your app? Can you share some code here?

An example of reading a file line by line and add each line to the listView would be:

System.IO.StreamReader sr = new System.IO.StreamReader("path_to_your_file"); // create stream reader

string fileName;
while ((fileName = sr.ReadLine()) != null) // read the file line by line
    projectRootNode.Nodes.Add(fileName); // add each line to the listview

sr.Close(); // close the stream

Okay thats a good start thanks! The only problem with using your code is that the actual list of files starts 5 lines down. The other lines is infromation such as directory path on disk, title, date of creation, type etc.

I have tonnes of project code, however I havent even started to tackle this problem yet, I've been focusing on creating projects, adding files to them, updating projeict file and treeNodes etc.

When I start (soon hopefully) i'll post my solution on here :)

If the lines that contain filenames are unique you can use Regex to identify them. Otherwise you will have to create an exclusion list.

Glad that you found it helpfull.

One last advice.. use standards. Unless standards don't meet your requirements (and I highly doubt that) you SHOULD use it.

I recommend you use ini or xml formats in your .proj file, here are some useful links:
- ini file
- ini file parser
- learn xml
- xml c# example
- Google is your friend

Wish you luck.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.