i have some PHP code that saved in database. i want write a program that read php from database and then load in notepad++ and after edit save to database.
it is possible use notepad++ in our php project as editor?
or it is possible load notepad++ to our c# project and use as editor?
question: how can load notepad++ to (c# or php) project as editor?
In C# you could first save your PHP code to a temporary file in C:\temp\ (or somewhere you specify)
Then
System.Diagnostics.Process.Start(@"C:\Program Files\Notepad++
otepad++.exe", @"C:\temp\tmpfile.php");
(I'm guessing at the file path names, change as appropriate)
Then as Võ Quang Hòa says use the FileSystemWatcher
class to watch for the file to be saved, and when it is, your program will read it and save it back to the DB.
FileSystemWatcher fsw = new FileSystemWatcher(@"C:\temp\");
fsw.Filter = "tmpfile.php";
fsw.NotifyFilter = NotifyFilters.LastWrite;
fsw.Changed += new FileSystemEventHandler(fsw_Changed);
fsw.EnableRaisingEvents = true;
and add function
private static void fsw_Changed(object sender, FileSystemEventArgs e)
{
// Code to save file to DB and delete temp file.
}
As my understand about your question (maybe wrong) 1. From your program, when click on a file, you call notepad++ by using this command
<Path to your notepad++> -n<line> <Path to your source code file>