, use Directory.delete ("c:\\asp");.
--------------------------------------------------------------------------------
Reading, writing, and creating Files
Because the. NET Framework provides a class for retrieving information about a particular directory (the DirectoryInfo CLA SS), it should come as no surprise that it also provides a class for accessing file information. This class, aptly named FileInfo, contains a number of properties similar to the DirectoryInfo class. For example, the Att
(IntIndex = 0; index
If(Arr [index] = sValue)
Return True;
Return False;
}
If a match is found, the program returns True immediately and exits. If the function at the end of the array does not return True, the value to be searched is not in the array and the function returns False.
The following is a program for testing our sequential search implementation:
UsingSystem;
UsingSystem. IO;
Public Class Chapter4
{
Static VoidMain ()
{
Int[] Numbers =New Int[100];
StreamReaderNumFile =File.
() method displayresultstringbyusingread (Reader) ;}} using (filestream stream = file. openread (txtfi Lepath) {// use encoding. ASCII to try using (streamreader reader = new streamreader (stream, encoding. ASCII, false) {// streamreader. readblock () method displayresultstringbyusingreadblock (Reader) ;}// you can use the file location to directly obtain streamreader. By the way, encoding is used. default using (streamreader reader = new streamreader (txtfilepath, encoding. default, false, 123
the text content one at a time, but should use stream to read the content.. NET encapsulates the StreamReader class for us, which is designed to read characters from a byte stream in a particular encoding. The method of the StreamReader class is not a static method, so reading a file using that class first instantiates the class, providing the path to read the file when it is instantiated. There are many ways to instantiate a StreamReader class. Here are some of the things I've listed:StreamRea
Workbooks. opentext (filename, origin, startrow, ype, textqualifier, delimiter, tab, semicolon, comma, space, other, otherchar, fieldinfo, textvisuallayout, delimiter, thousandsseparator, delimiter, local)
For more information about the meanings of the preceding parameters, see the help of VBA. In actual programming, it is generally not necessary to process these complex parameters. You can use a recording macro to obtain the VBA code for opening a te
statement function ");
}
Finally
{
// Standard writing method. The following statement can also be directly written as W. Dispose ()
If (W! = NULL) (idisposable) W). Dispose ();
}
# Endif
// You can declare an object in the using statement or declare an object before the using statement, as follows:
Textreader r = file. opentext ("E: // test.txt ");
Using (r)
{
String stringd = R. readtoend ();
Console. writel
writing code. Let's take a look at the following two methods of coding:Method 1: Using (streamreader sr = file. opentext (PATH )){Filter = new list String S = "";While (S = Sr. Readline ())! = NULL){Filter. Add (s );}}
Method 2: Using (streamreader sr = new streamreader (path, encoding. Default )){Filter = new list String S = "";While (S = Sr. Readline ())! = NULL){Filter. Add (s );}}
The first method uses the static file method
Mr. Jon jarger is a person with rich experiences. His articles are simple and thought-provoking. If you can browse on his website, you will certainly benefit a lot. Although this article is relatively simple, it will inevitably lead to errors in translation. I hope you will give me more advice.PS: This article is very simple. If you feel that you have reached a certain level, please do not waste time ^_^
1. Painful stylized error handling
Before an exception occurs, the most classic way to handl
creating a class instance. Suppose you want to delete a file with these two classes, you can do this:
' Use the File class
File.delete (FileName)
' Use the FileInfo class
Dim Finfo as FileInfo
Finfo = new FileInfo (fileName)
Finfo.delete ()
Note that the Delete method of the file class takes only one parameter, the file to be deleted, and can be invoked without instantiating the file class. Looking at the FileInfo class again, its Delete method takes no arguments, because the file name is speci
In. NET in the System.IO.File and System.IO.FileInfo in the OpenText and appentext several methods are used UTF-8 encoding operation files. This causes garbled behavior if the operation is not a file written with UTF-8 encoding !!!
The workaround is to use a byte throttling operation on the text file, that is, not used. NET provides the OpenText and the Appentext and so on several methods, but is the text a
: CaseResponsestate.cancel://failed or canceled authorization information to clear the specified platformSSDK. Cancelauthorize (type); Break; CaseResponsestate.beginupload: Break; default: Break; } }}Write a tool class that reads and writes files.usingSystem.IO;/// ///a tool class that reads and writes files. ///the data that is returned when you view the SHARESDK authorization. /// Public Static classutility{ Public Static voidWriteFile (stringPathstringName
Official website to explain the operation of the document:open(file,mode= ' R ',Buffering=-1,Encoding=none,Errors=none,Newline=none,closefd=true,Opener=none)
Character
meaning
'r'
Open for reading (default)
'w'
Open for writing, truncating the file first
'x'
Open for exclusive creation, failing if the file already exists
'a'
Open for writing, appending to the end of the file if i
Studio 2005\projects\consoleapplication2\c Onsoleapplication2\bin\debug\temp. * D:\Documents and Settings\cliffc\local settings\temp\8\ are the location for temporary files. * D:\Documents and Settings\cliffc\local settings\temp\8\tmp3d.tmp is a file available for use. */ }} Create a file with FileInfo Using system;using system.io;class Test {public static void Main () {//Gets the cache path through the path object string path = Path.gettempfilename ();
Cursor
ThisWorkbook
DefaultFilePath
UserControl
DefaultSaveFormat
Workbooks
Displayformulabar
Worksheets
Displayfullscreen
DisplayScrollBars
Name
DisplayStatusBar
Workbooks Collection Object--the collection of all workbook objects currently open
Property
Metho
Before you write, declare that I am very vegetable, and very lazy.
For a reason, look at the reasons first.
I want to pass a file through the network from Java to C #, because I am lazy, choose the Web service, and just want to pass the simple type, so I think of Base64, so I decided to use the Base64 code after the Java to provide Web service, called by C #.
Must first into the Base64 code bar, with Java will not be compiled, choose the C # code, have to save into a text file, read in Java, com
= "";! ($domain-like "www.*.*"); $domain =read-host "Input domain")
{
Write-host-foregroundcolor "Green" "please give a valid domain name."
}
Please give a valid domain name.
Input domain:www
Please give a valid domain name.
Input domain:mossfly.com
Please give a valid domain name.
The following example shows reading a text file line by row
Copy Code code as follows:
for ($file =[io. File]::opentext ("C:autoe
:";Filedetail.text + + strfile2show+ "Filedetail.text + = "File Size";Gets the size of the file, and then transforms the unit to KBFiledetail.text + = (fi. length/1024). ToString () + "K Filedetail.text + = "Create file time:";Get the date the file was createdFiledetail.text + = fi. Creationtime.tostring ();Filedetail.text + = "Last accessed time:";Get last accessed date of fileFiledetail.text + = fi. Lastaccesstime.tostring () + "Filedetail.text + = "Last Write time:";Get the last write date of
First, read the text file in the following steps:
1, create FileSystemObject object instance;
2, using the OpenTextFile method of FileSystemObject object to return a TextStream object instance;
3. Read the data from the file using the read, ReadLine, ReadAll, Skip, or SkipLine method of the TextStream object.
Note: Below we take the OpenTextFile method each parameter to make the annotation:
1) Txtfile: the instance name of a TextStream object returned by the
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.