(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 datatable getdatatablefromstring (string tmphtml){S
created. Read content from a file Reading content from a file is roughly the same as writing content to the file, but pay attention to the following two things: 1. Use the streamreader class for File Reading 2. When the Readline method is used, an empty string ("") is used to mark the end of the text file to be read. The write code is now used to read the content from the aspnet.txt file created earlier: In ASP. NET, the entire process of file processing is centered around the namespace s
filestream in the specified path.
20
Openread
Open an existing file for reading.
21
Opentext
Open an existing UTF-8 encoding text file for reading.
22
Openwrite
Open an existing file for writing.
23
Readallbytes
Open a file, read the file content into a string, and then close the file.
24
Readalllines
Open a text file, read all the lines of the file into a string array, and th
streamMyfilestream1.write (mywritebytearray, 0, numberofbytestowrite );// Close the streamMyfilestream1.close ();// Close the streamMyfilestream2.close ();}}}The myfilestream1 object is instantiated using the specified path and creation mode. The Creation Mode filemode is an enumeration type and also includes:
Append
You can open an existing file and find the end of the file. filemode. append can only be used with fileacces. Write (write permission ).
Create
Cr
1. method for obtaining the installation path of the program application. startuppath
For example:
String Path =Application. startuppath + "\ wartercode. xml";
It is equivalent to server. mappath () in ASP. NET ();
2. Operate txt
(1) Determine whether the text exists. If it does not exist, create a text and write data to it. If it exists, read the data in it.
String Path = @ "C: \ wartercode.txt ";Fileinfo Fi = new fileinfo (PATH );If (! Fi. exists){// If it does not exist, create a textStreamwr
I wanted to write and write in five minutes .. I found that vs2003 could not use 1.1 to write one on the machine ..
Every time, we use a new Google .. This is no exception .. Grandma's .. We found that it was actually 2.0 of the Code .. Helpless. I found myself .. After 10 minutes, I wrote some code ..
Some source code is as follows (the following code is available for download ):
------------------------------------------------------------
XML code:
--------------------------------------------
A few days ago, I/O processing encountered a problem that could not be operated.The file "D: \ log \ cargoabc \ logfilecargoabc.txt" is being used by another process. Therefore, this process cannot access the file.Logfilecargoabc.txt is a log file and may be written to it by another program from time to time.I/O streams need to be used to read log files and display them in log query.1. filestream FS = file. openread (URL );Streamreader sr = new streamreader (system. Io. Stream) FS, system. Text.
1. It is convenient to write --------- to cells one by one, but the speed is slow.
2. Using the Excel feature, the data in each column is first separated by \ t, each row is separated by \ r \ n, and finally pasted to the clipboard ---------- with a slightly higher speed, however, if a copy and paste task is executed externally, errors may occur.
3. assign values directly to the corresponding area of the array through arrays. ---------- Very convenient for datatable. You can assign a value dir
This article provides a detailed analysis of file traversal information using the iterator. For more information, see
1. iterate the row of the file
The code is as follows:
Public static IEnumerable
ReadLines (string fileName)
{
Using (TextReader reader = File. OpenText (fileName ))
{
String line;
If (line = reader. ReadLine ())! = Null)
{
Yield return line;
}
}
}
Static void Main ()
{
Foreach (string line in Iterator.
. Empty;if (OFD. ShowDialog() = = System. Windows. Forms. DialogResult. OK) TextBox1. Text= OFD. FileName;else TextBox1. Clear();button2The function is to perform the assembly and generate the binary bytecode file, the main code is as follows:if (textBox1. Text= = String. Empty) return;Labeldict. Clear();Binarylength = (UInt16) numericUpDown1. Value;FileInfo fi = new FileInfo (textBox1. Text);BinaryWriter output;FileStream fs = new FileStream (Path. Combine(FI. DirectoryName, fi. Name+". Sab"),
time, the portal to receive the creation time of the order of carding, found the audit log time inconsistencies, timezone problems.Time consistency, time zone issues are business rules that large, complex systems must pay attention to and be careful about, and find the following problems.(1), due to the use of the system platform Cordys products are foreign products, time is the standard time, with Beijing, 8 time zones, that is, less than 8 hours.(2), Oracle time conversion characters, minutes
:\CopyWang.txt", @ "D:\A\movewang.txt");
Set file properties to read-only, hide
File.setattributes (@ "D:\copywang.txt", Fileattributes.readonly | Fileattributes.hidden);//satisfy multiple attributes at the same time, you must use a bit or (|).
Judging if the file is not present
if (File.exists (@ "D:\copywang.txt"))//If there are even hidden files can be found
{
File.setattributes (@ "D:\copywang.txt", fileattributes.readonly);//After you reset the properties, the hidden files are also displa
request to the target activity from the source request activity through a intentSOURCE ActivtyPrivate Intent openwelcomeactivityintent = null;TextView Text=null;@Overrideprotected void OnCreate (Bundle savedinstancestate) {Super.oncreate (savedinstancestate);Setcontentview (R.layout.main);Openwelcomeactivityintent = new Intent ();Set the next activity to opentext= (TextView) Findviewbyid (r.id.test);Text.setonclicklistener (New Onclicklistener () {pu
[" + sheetname + "$]", Conn );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 /
affected rows is 1)-- 1. for multi-country texts, be sure to use Unicode to judge!-- 2. Korean Unicode split: 12592-> 12687 44032-> 55203Websites: http://www.buja.8u8.com/eeeeee.htm
Create Function HW (@ STR 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 @
these two class libraries in reference, so we can find a way to find them. First, mssqlserver2008 is installed on my computer,
Go to X: \ Program Files \ Microsoft SQL Server \ 100 \ SDK \ assemblies to find
Microsoft. sqlserver. connectioninfo. dll
Microsoft. sqlserver. SMO. dll
Microsoft. sqlserver. Management. SDK. SFC. dll)
Then manually add the application. The third dll must be referenced. Otherwise, an error will be reported.
See belowCode:
// Card filling operation
Privat
1. Create a text filePublic class fileclass{Public static void main (){Writetofile ();}Static void writetofile (){Streamwriter SW;Sw = file. createtext ("C: \ mytextfile.txt ");Sw. writeline ("God is greatest of them all ");Sw. writeline ("this is second line ");Sw. Close ();Console. writeline ("File Created sucacessfully ");}}2. Read filesPublic class fileclass{Public static void main (){Readfromfile ("C: \ mytextfile.txt ");}Static void readfromfile (string filename){Streamreader SR;String S;S
(Write permission)Create creates a new file that is overwritten if the file exists, no newCreateNew Create new file, if any, there are exceptionsOpen opens an existing file and throws an exception if it is openIf the file exists, it is open, if it does not exist, it is created if there is a file.
The Myfilestream2 object is instantiated with FileInfo, and the FileInfo method has open,openreade,opentext,create,createtext.
The Read and write (write)
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.