Visit the blog Park today to see other people's Code I think it is good to write and want to copy it down, but the code has a line number. I always copy the code first and then delete one line, however, it would be too much trouble if you always do this in the future, so I finally decided to write a tool and software to share it with everyone, hoping it would be helpful. Program The main code for Microsoft Visual Studio 2005 is as follows: 1 Using System;
2 Using System. Collections. Generic;
3 Using System. componentmodel;
4 Using System. Data;
5 Using System. drawing;
6 Using System. text;
7 Using System. Windows. forms;
8
9 Using System. IO;
10 Namespace Clearcodelinenum
11 {
12 Public Partial Class Form1: Form
13 {
14 Public Form1 ()
15 {
16 Initializecomponent ();
17
18 Openfiledialog1.initialdirectory = Environment. getfolderpath (environment. specialfolder. Revoke topdirectory );
19 Openfiledialog1.filename = Null ;
20 }
21
22 Private Void Btnopenfile_click ( Object Sender, eventargs E)
23 {
24 If (Openfiledialog1.showdialog () = Dialogresult. OK)
25 {
26Txtfilepath. Text=Openfiledialog1.filename;
27Btnclearcode. Focus ();
28}
29 }
30
31 Private Void Btnclearcode_click ( Object Sender, eventargs E)
32 {
33 If (File. exists (txtfilepath. Text ))
34 {
35 Using (Streamreader Reader = New Streamreader (txtfilepath. Text, encoding. Default, True ))
36 {
37 Int Index = Txtfilepath. Text. lastindexof ( ' . ' );
38
39 /**/ ///Strextension is the file extension, we need to maintain
40///Cleared file's extension
41 String Strextension = Txtfilepath. Text. substring (INDEX );
42 Using (Streamwriter writer = New Streamwriter (txtfilepath. Text + " . Clear " + Strextension ))
43 {
44 /**/ ///Linenum will be the array of numbers that need removing
45///From every line code.
46 Char [] Linenum = " 0123456789 " . Tochararray ();
47 String Code = Null ;
48 While (Code = Reader. Readline ()) ! = Null )
49 {
50 /**/ ///Remove the spaces at the front of the line, otherwise
51///It will stop the operation of the next line code.
52 Code = Code. trimstart ();
53 Code = Code. trimstart (linenum );
54 Writer. writeline (CODE );
55 }
56 }
57 }
58 MessageBox. Show ( " Row number removed " , " Qingfeng bamboo " , Messageboxbuttons. OK, messageboxicon. Exclamation );
59 }
60 Btnopenfile. Focus ();
61 }
62
63 Private Void Btncopypath_click ( Object Sender, eventargs E)
64 {
65 If (File. exists (txtfilepath. Text ))
66 {
67 Fileinfo = New Fileinfo (txtfilepath. Text );
68 System. Diagnostics. process. Start (fileinfo. directoryname );
69 Btnopenfile. Focus ();
70 }
71 }
72 }
73 }
Well, now, as long as the code above is copied and saved as text, this program can be easily removed.
Source codeDownload: clearcodelinenum.rar