كائن ملف ASP
يتم استخدام كائن الملف لإرجاع معلومات حول ملف محدد.
مزيد من الأمثلة
كيفية الحصول على تاريخ ووقت آخر تعديل لملف معين.
كيفية الحصول على تاريخ ووقت آخر مرة تم فيها الوصول إلى ملف محدد.
كيفية إرجاع سمات ملف محدد.
كائن الملف
يتم استخدام كائن الملف لإرجاع معلومات حول ملف محدد.
للعمل مع خصائص وأساليب الكائن File ، سيكون عليك إنشاء مثيل لكائن File من خلال كائن FileSystemObject. أولا؛ إنشاء كائن FileSystemObject ثم إنشاء كائن ملف من خلال أسلوب GetFile للكائن FileSystemObject أو من خلال خاصية الملفات في كائن المجلد.
تستخدم التعليمات البرمجية التالية طريقة GetFile للكائن FileSystemObject لإنشاء مثيل لكائن File وخاصية DateCreated لإرجاع التاريخ الذي تم فيه إنشاء الملف المحدد:
مثال
<%
Dim fs,f
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.GetFile("c:\test.txt")
Response.Write("File created: " & f.DateCreated)
set f=nothing
set fs=nothing
%>
خصائص كائن الملف وطرقه موضحة أدناه:
الخصائص
Property | Description |
---|---|
Attributes | Sets or returns the attributes of a specified file |
DateCreated | Returns the date and time when a specified file was created |
DateLastAccessed | Returns the date and time when a specified file was last accessed |
DateLastModified | Returns the date and time when a specified file was last modified |
Drive | Returns the drive letter of the drive where a specified file or folder resides |
Name | Sets or returns the name of a specified file |
ParentFolder | Returns the folder object for the parent of the specified file |
Path | Returns the path for a specified file |
ShortName | Returns the short name of a specified file (the 8.3 naming convention) |
ShortPath | Returns the short path of a specified file (the 8.3 naming convention) |
Size | Returns the size, in bytes, of a specified file |
Type | Returns the type of a specified file |
طرق
Method | Description |
---|---|
Copy | Copies a specified file from one location to another |
Delete | Deletes a specified file |
Move | Moves a specified file from one location to another |
OpenAsTextStream | Opens a specified file and returns a TextStream object to access the file |