كائن ASP TextStream
يتم استخدام كائن TextStream للوصول إلى محتويات ملف نصي.
مزيد من الأمثلة
ملف نصي كيف تقرأ من ملف نصي.
ملف نصي. كيفية قراءة جزء من ملف TextStream فقط.
واحد من ملف نصي. كيفية قراءة سطر واحد من ملف TextStream.
ملف نصي. كيفية قراءة جميع الأسطر من ملف TextStream.
ملف نصي. كيفية تخطي عدد محدد من الأحرف عند قراءة ملف TextStream.
ملف نصي. كيفية تخطي سطر عند قراءة ملف TextStream.
كيفية إرجاع رقم السطر الحالي في ملف TextStream.
كيفية الحصول على رقم العمود للحرف الحالي في ملف.
كائن TextStream
يتم استخدام كائن TextStream للوصول إلى محتويات الملفات النصية.
تقوم الكود التالي بإنشاء ملف نصي (c: \ test.txt) ثم يكتب بعض النص إلى الملف (المتغير f هو مثيل لكائن TextStream):
<%
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.CreateTextFile("c:\test.txt",true)
f.WriteLine("Hello World!")
f.Close
set f=nothing
set fs=nothing
%>
لإنشاء مثيل لكائن TextStream ، يمكنك استخدام أساليب CreateTextFile أو OpenTextFile للكائن FileSystemObject ، أو يمكنك استخدام أسلوب OpenAsTextStream الخاص بالكائن File.
خصائص وطرق كائن TextStream موضحة أدناه:
الخصائص
Property | Description |
---|---|
AtEndOfLine | Returns true if the file pointer is positioned immediately before the end-of-line marker in a TextStream file, and false if not |
AtEndOfStream | Returns true if the file pointer is at the end of a TextStream file, and false if not |
Column | Returns the column number of the current character position in an input stream |
Line | Returns the current line number in a TextStream file |
طرق
Method | Description |
---|---|
Close | Closes an open TextStream file |
Read | Reads a specified number of characters from a TextStream file and returns the result |
ReadAll | Reads an entire TextStream file and returns the result |
ReadLine | Reads one line from a TextStream file and returns the result |
Skip | Skips a specified number of characters when reading a TextStream file |
SkipLine | Skips the next line when reading a TextStream file |
Write | Writes a specified text to a TextStream file |
WriteLine | Writes a specified text and a new-line character to a TextStream file |
WriteBlankLines | Writes a specified number of new-line character to a TextStream file |