":Xnode. itemname = XTR. readstring ();Xcol. Add (xnode );Break;Default:Break;}}}XTR. Close ();}}
Public sealed class enhancedtreenode: system. Windows. Forms. treenode{Private int m_intitemid =-1;Private string m_stritemname = string. empty;
Public enhancedtreenode (){// Add constructor logic here}
Public enhancedtreenode (string itemname, int Itemid){M_intitemid = Itemid;M_stritemname = itemname;This. Text = itemname;}
Public int Itemid{Get {return m_intitemid ;}Set {m_intitemid = value ;}}
P
| fileattributes. Hidden );}In addition to common read-only and hidden attributes, files include archive, system, and temporary. For details about file attributes, see the description of fileattributes in msdn.(7) method for determining whether a file exists: file. existThe method is declared as follows:Public static bool exists (string path );The following code checks whether the c: \ tempuploads \ newfile.txt file exists. If the file exists, copy the file first, delete it, and then move the c
Using system. IO;Using itextsharp. text;Using itextsharp.text.pdf;// Icsharpcode. sharpziplib. dll and itextsharp. dll must be referenced in the project.Public String txtfilepath;Public String savepdfpath; // path for saving the PDF file# Region read TXT contentPrivate string readxieyi (string filepath){String xieyi = "";Fileinfo Fi = new fileinfo (filepath );Streamreader sr = Fi. opentext ();Xieyi = Sr. readtoend ();Sr. Close ();Return xieyi;}# Endre
(. NET Framework 2.0)
2. Concept of stream:
A stream is an object used to transmit data. Data transmission has two directions:
If the data is transmitted from the external source to the program, this is the read stream; if the data is transmitted from the program to the external source during the summer vacation, This is the write stream.
3. filestream class: used to read and write binary files. To construct a filestream instance, you need the following four pieces of information: (. NET Framew
, password, writerespassword, ignorereadonlyrecommended, origin, delimiter, editable, y, converter, addtomru, local, corruptload)
Filename is a required parameter, indicating the name of the workbook to be opened. If no path is specified, it indicates the current path. The other 14 are optional parameters, except Password parameters, which are rarely used. For specific meanings, see the help of VBA.
Example:
Workbooks. Open "F: test.xls"
Open the test.xls file on the fdisk.
2. Open a text file
Y
method to create a series of changing methods. Each method has a list of different parameters.
Scope:The default scope of the shared method is public. We can also set the sharing method to friend, protected, or private in the Declaration. In fact, when a method is overloaded, we have different scopes as long as the parameter list is different.
Usage:How is the sharing method used? Let's look at an example. When we want to open a text file for the input, we can use a shared code in the
This article is a learning note, C # advanced programming 6 chapter 25 file and registry operations
1. Manage File Systems
1. File directory is a static class. You can use these classes to call only one operation of a File or folder.
FIleInfo DirectoryInfo is a sealed class and needs to be instantiated. Therefore, if you operate a file multiple times, you can use these classes.
2. FileInfo can execute Open (), OpenRead (), OpenText (), OpenWrite (), C
();If (PB. Ad. Street! = "")Break;Else{Outmsg (1 );}}
While (true){Try{Console. writeline ("enter your house number :");PB. Ad. No = convert. touint32 (console. Readline ());Break;}Catch{OutMsg (2 );}}
Info = "your information is as follows: \ r \ n" + "name:" + pb. name + "\ r \ n age:" + pb. age + "\ r \ nTel: "+ pb. phone +" \ r \ n address: "+ pb. ad. city +" city "+ pb. ad. street +"Street" + pb. ad. no + ";Write_info = "name:" + pb. name + "\ r \ n age:" + pb. age + "\ r \ n Tel:" + pb. p
);Oledbdataadapter mydata = new oledbdataadapter (myoledbcommand );Mydata. Fill (RS );Conn. Close ();}}}Else{System. Io. streamreader tmpstream = file. opentext (filepath );String tmpstr = tmpstream. readtoend ();Tmpstream. Close ();Rs = getdatatablefromstring (tmpstr );Tmpstr =;}Return Rs;}/// /// Convert the data of the specified HTML string to a able object. The data is processed based on special characters such as /// /// /// Private Static datat
In wince, relative paths cannot be used. absolute paths must be used to locate files.
For example, the abc.txt file under the Program Files \ testprogramvisual directory can only be used
Program Files \ testprogram \ abc.txtto locate the location, but cannot use abc.txt to locate the location.
For example:
Private void button#click (Object sender, eventargs E){
String Path = "Program Files \ testwince \ configpio.txt ";Using (streamreader sr = file.
Information/// Public foundationservice{Get{Return m_found;}}/// /// Order Management/// Public orderservice{Get{Return m_order;}}Public systemvm (){Loadbusinessobj ();}/// /// Return the template type that can be selected by the system based on the template type./// /// /// Public xmlnodelist getxmljavascriptbytype (string stype){Xmlnodelist = xmljavascript. selectnodes ("// item [@ type = '" + stype + "']");If (xmlnodelist. Count {Throw new exception ("the node of Type [" + stype + "] cannot
file for writing text.· Opentext: open an existing text file for reading.But the above method mainly on the UTF-8 encoding text operations, which is not flexible enough. We recommend that you use the following code to operate the TXT file.· Read the TXT file. The sample code is as follows: Streamreader txtreader = new streamreader (@ "C: \ tempuploads \ newfile.txt", system. Text. encoding. Default );String filecontent;Filecontent = txtreader. readen
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.