Mycodebar my code fragment management tools

Source: Internet
Author: User
Tags mail code mailmessage smtpclient

I haven't written blogs for a long time. It seems that I have lost the meaning of blogs, so I decided to keep it in the future .. Today's weather is overcast, beef noodles are eaten again at noon, and the same thing is about to crash every day. There is no way, there is only such a fast food nearby... continue to stick to it.

Recently I found thatCodeThere will always be a method that I have done before, but I cannot remember how to implement it. Alas ~~ There is no way, so I will write a code snippet for management.ProgramWhen I use it, I can directly find the corresponding code. although there are many similar tools that can be loaded into vs.net, I feel that this feature is too troublesome. I just want to record it, so let's write it by yourself.

The main interface is as follows:

The toolbar stays in the taskbar.

Briefly introduce the functions of this tool.

1. You can call the Google Code search function to find the relevant code.

2. You can save, edit, or delete fragments of existing code.

3. You can back up all the code fragments to the specified mail to back up them.

4. Restore the backup... (there is no time to write this section. Please try again later)

Main development ideas... this is actually very simple. The XML file is used to record the title and the path of the file storing the code fragment. In this way, when you click the copy function, the code is automatically obtained under the corresponding path, then copy it to the clipboard.

The main function is to display the saved code as a menu. When you click it, save it to the clipboard. For example:

The main implementation method of this program

The Google Code search function is very simple... it is the process class that calls the Code Search URL, just substitute the parameter.

Bar mainly uses the BHO technology. You can go to codeproject to check bandobject to find the corresponding strength.

But do not display the attribute of the bar class in IE, as long as it is displayed in the taskbar.

[Bandobject ("mycodebar", bandobjectstyle. Horizontal | bandobjectstyle. taskbartoolbar, helptext = "My code bar")]

In this case, OK.

Backup mode. It is mainly used to compress all files into ZIP files and save them by mail.

Mail Code:

String smtpserver = "smtp.126.com ";
String username = "XXXXXX@126.com ";
String userpwd = "XXXX ";
String emailfrom = "XXXX@126.com ";

Smtpclient client = new smtpclient (smtpserver );
Client. Credentials = new networkcredential (username, userpwd );

Client. deliverymethod = smtpdeliverymethod. Network;

Mailmessage email = new system. net. Mail. mailmessage ();
Email. From = new mailaddress (emailfrom );
Email. to. Add ("XXXXX@126.com ");
Email. Body = "mycodebar backup file, see attachment ";
Email. bodyencoding = system. Text. encoding. utf8;
Email. Subject = "mycodebar backup file ";
Email. subjectencoding = system. Text. encoding. utf8;
Email. isbodyhtml = true;
Attachment A = new attachment (tempname );
Email. attachments. Add ();

Client. Send (email );

Code of the compressed file:

Try
{
Savefiledialog SFD = new savefiledialog ();
SFD. Title = "backup file ";
SFD. Filter = "Zip | *. Zip | all | *.*";
If (SFD. showdialog () = dialogresult. OK)
{

String tempname = SFD. filename;

Filestream outs = file. Create (tempname );

Icsharpcode. sharpziplib. Zip. zipoutputstream TOS = new icsharpcode. sharpziplib. Zip. zipoutputstream (outs );
Filestream ins = NULL;

String [] filenames = directory. getfiles (common. filedir );
Foreach (string file in filenames)
{
INS = file. openread (File );

Byte [] buffer = new byte [ins. Length];

INS. Read (buffer, 0, buffer. Length );
INS. Close ();
String tempfile = file. substring (3, file. Length-3 );
Icsharpcode. sharpziplib. Zip. zipentry tarentry = new icsharpcode. sharpziplib. Zip. zipentry (tempfile );
Tarentry. size = buffer. length;

ToS. putnextentry (tarentry );

ToS. Write (buffer, 0, buffer. Length );
ToS. closeentry ();
}

INS = file. openread (common. configfilepath );

Byte [] buffer2 = new byte [ins. Length];

INS. Read (buffer2, 0, buffer2.length );
INS. Close ();
String tempfile2 = Common. configfilepath. substring (3, common. configfilepath. Length-3 );
Icsharpcode. sharpziplib. Zip. zipentry tarentry2 = new icsharpcode. sharpziplib. Zip. zipentry (tempfile2 );
Tarentry2.size = buffer2.length;

ToS. putnextentry (tarentry2 );

ToS. Write (buffer2, 0, buffer2.length );
ToS. closeentry ();

ToS. Close ();
MessageBox. Show ("OK ");
}
}
Catch (system. Exception exp)
{
Common. messageboxerror (exp. Message );
}

Nothing left. The rest is the management logic.

Currently, after bandobject is used, although it can be loaded into the taskbar, after restarting the computer, it will not automatically load mycodebar but load the Quick Start... I have not found the cause of this problem. It may be that my GUID is faulty .. check it later. Tell me if anyone has encountered such a problem. :-)

File Download

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.