How to access properties of files and folders on the server?
Accessing the properties of the files and the folders on the server can be easily
accomplished with the help of the FileSystemObject methods. You need to create
an instance of the FileSystemObject and then use the methods of that object. There
are several properties and methods for the FileSystemObject that allows you to
work with the files on the server.
We shall see some code that works on the files on a server. For this we need to have some files on the server. Assuming that you have a file called Log.txt in the same directory as that of the .asp file that has the code to access the properties of the files; the code could be something like given below:
second line of the code given above has the declarations for the objects that
will be used to access the properties of the files. An instance of the FileSystemObject
is created in the 3rd and the 4th line. The GetFile method of the FileSystemObject
is used to access the file Log.txt. We are using the Server.MapPath
method to access the file. You know that the MapPath is used to convert the relative
path to the physical path which the gives the path exactly starting with the drive
You should check the code by replacing the Line 7 of the code with other properties and methods so that you know how those properties are also accessed.
For example the Line 7 could be modified as:
some of the properties that can be accessed. There are also other properties
like, Name, ShortPath, ParentFolder, and Type. For more details and code
samples on these you can always refer the documentation provided for these
in the Microsoft website. FREE
to our mailing list and receive new articles Note
: We never rent, trade, or sell my email lists to Visit
.NET Programming Tutorial Homepage ______________________________________________________
to our mailing list and receive new articles
: We never rent, trade, or sell my email lists to
Visit .NET Programming Tutorial Homepage
| How to Parse an XML Document using DOM | Understanding Code Management in .NET | Understanding Enterprise Transaction Services in .NET | Understanding .NET Interface-Based Programming | Understanding Security Management in Web Services | Understanding SOAP Message and Delivery Structure | Understanding the Basics of Language Integrated Query (LINQ) | Understanding the Basics of Web Services using .NET | Understanding the Basics of XPath |
Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.
Copyright - © 2004 - 2023 - All Rights Reserved.