exists.
{
Copyfile (); // copy a file
Deletefile (); // delete an object
Movefile (); // move the file
}
Else
{
Makefile (); // generate a file
Openfile (); // open the file
Setfile (); // set file attributes
}
In addition, the file class provides more support for text.
· Appendtext: append text to an existing file.
· Createtext: Creates or opens a new file for writing text.
· Opentext: open an existing text file for reading.
But the above method mai
(After criticism and guidance from many netizens, this method does not read files from the memory, but reads files one byte by byte, which is much slower than the method used to read Delphi bytes into the memory. This method is only suitable for old machines. If the memory is not enough, the current memory is very cheap. Therefore, this method is out of date. The following is some advice from netizens, the Readline method is used. The speed is about 6 seconds .)
Public
Static Ilist Lon
nvarchar (100 ))Returns intAsBeginDeclare @ A intSet @ A = 0While @ STR BeginSet @ A = (case when Unicode (left (@ STR, 1) between 12592 and 12687Or Unicode (left (@ STR, 1) between 44032 and 55203Then 1Else 0 end)Set @ STR = right (@ STR, Len (@ Str)-1)EndReturn @End
-- Call:Declare @ A nvarchar (100)Set @ A = n'abc's country 123'Select DBO. HW (@)
-- Return: 1
Set @ A = n' ABC China 123'Select DBO. HW (@)
-- Return: 0
4. Why are the Chinese characters read from the file garbled?
. currentdomain. basedirectory, file );If(File. exists (cnblogs )){Using(Streamreader reader = file. opentext (cnblogs) {rtfcnblogs. Text = reader. readtoend ();}}
Added the complete file name path, which is the correct method for reading and writing files. For ASP. NET applications, you can use server. mappath instead,
Or httpcontext. Current. Request. physicalapplicationpath.
Cross-thread access control
Delegate VoidDsettext (string text );
: famous search engines such as Lycos, Hotbot, and Yahoo are used in English. Enter detailed keywords (it must be characteristic to prevent searching for too many items ), adding a PDF at the end may have better results. If it is inconvenient, go to www.5566.org and click search. More than a dozen engines are collected, which is enough for you to check. However, Baidu and Google are generally better! Lycos is also good. Key words are very important. You need to master some skills. Otherwise, it'
: The following process is required by the component designer'You can use the component designer to modify this process.'Do not use the code editor to modify it.Components = new system. componentmodel. ContainerEnd sub
# End Region
Sub application_start (byval sender as object, byval e as eventargs)'Triggered when the application is startedDim count as integer = 0Dim SRD as streamreaderDim file_path as string = server. mappath ("counter.txt ")SRD = file. ope
/// /// Read the SQL script file. Note: The file is saved in UTF-8 format./// Each Execution Unit ends with an exclusive go/// Perform operations such as table creation and table structure modification./// /// /// Public static list {If (! File. exists (varfilename )){Return NULL;}
Streamreader sr = file. opentext (varfilename );
List
String commandtext = "";
String varline = "";
While (Sr. Peek ()>-1){Varline = Sr. Readline ();If (varline. T
, eventargs e) {If (directory. exists (lbldisplaydir. text) = false) {return;} // output the directory structure to the text file using (streamwriter Sw = file. createtext ("a.txt") {directoryinfo di = new directoryinfo (lbldisplaydir. text); Sw. writeline (Di. name); foreach (var d in Di. getdirectories () {enumdirectory (D. fullname, "", SW);} SW. close () ;}// read the content from the text file if (file. exists ("a.txt") {using (VAR sr = file. opentext
Here: http://blogs.msdn.com/jfoscoding/archive/2006/01/14/512825.aspx
Here, only the knowledge points are sorted out:1. Obtain the selected content:(1) Use the RichTextBox. Document. Selection attribute(2) Access text in the "blocks" of the RichTextBox. Document. Blocks attribute
2. add content to RichTextBox in XAML:This is a RichTextBox. I can
3. Shorten the segment spacing, similar to You can use style to define the segment Spacing:This is my first paragraph... see how there is...A No space
attribute: returns the charttitle object, which indicates the title of the specified chart.
(3) charttype attribute: return or set the chart type.
(4) datatable attribute: return the datatable object, representing the chart data table.
(5) properties: return the wall object of a 3D chart.
4. Workbook object
This object represents the workbook.
(1) styles attribute: returns the styles set, indicating all styles of the specified workbook.
(2) Add method: used to create a workbook and set it as an
opened by the operating system. After opening, the file is truncated to 0 bytes.
Text Files
You can use the streamwriter and streamreader classes in the system. Io namespace to read and write file content. When creating these classes, you only need to pass the underlying stream as a constructor parameter:
FileStream fileStream = new FileStream(@"c:\myfile.txt", FileMode.Create);
StreamWriter w = new StreamWriter(fileStream);
You can also use static methods of the file class and fileinfo c
stream// Try//{T_sstreamreader = file. opentext (Spath + "//" + sname );//}// Catch (exception ex)//{// Return NULL;//}String t_sline; // the content of each lineArraylist t_javasraylist = new arraylist (); // containerWhile (t_sline = t_sstreamreader.readline ())! = NULL){T_javasraylist.add (t_sline); // Save the content of each row to the array linked list container.}T_sstreamreader.close (); // close the streamT_sstreamreader.dispose (); // destro
will be overwritten.
CreateNew
Specifies that the operating system should create a new file.
Open
Specifies that the operating system should open an existing file.
OpenOrCreate
Specifies that the operating system should open the file (if the file exists), otherwise, create a new file.
Truncate
Specifies that the operating system should open an existing file. Once the file is opened, it will be truncated to a size of 0 bytes.
o
Tags:. sh form. Text dir dia label Tin ToString Drop1. Code under the form private void Button1_Click (object sender, EventArgs e){OpenFileDialog of = new OpenFileDialog ();Of. Filter = "*.sql|*.*";Of. InitialDirectory = Application.startuppath; ;//application.startuppath;Of. Title = "Select the SQL File";if (of. ShowDialog () = = DialogResult.OK){Label3. Text = of. FileName; Button2. Enabled = true;}} private void Button2_Click (object sender, EventArgs e){var connstr = configurationmanager.app
A static page is generated.The instances written today mainly reflect the steps for replacement and storage.The template will not be done. directly use the whole body as a tag, replace the body of the dynamic page to be made into a static page with the data queried, and generate a static page. (Static homepage can do this ).
1. Use serever. Excute
StreamWriter sw = new StreamWriter (Server. MapPath ("html/Login.html"), false );
Server. Execute ("ShowColumn. asp tutorial x? Id = 1 page = 2 "
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.