Index
Chalker Jack L Swiaty Rombu 04 Meduza Tygrys w opalach
elektronika praktyczna 04 1997
rozdzial 04 (282)
rozdzial 04 (200)
rozdzial 04 (235)
rozdzial 04 (16)
rozdzial 04 (59)
Niewyzyskane Siły Życia
abc.com.pl 7
The Fellowship of a Ring
  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • souvenir.htw.pl

  • [ Pobierz całość w formacie PDF ]
    .We will make good use of recursion again later in the chapter.Listing 14.4 The DoCount procedure.Public Sub DoCount(f As Folder)Dim f1 As FolderNumFolders = NumFolders + f.SubFolders.CountNumFiles = NumFiles + f.Files.CountFor Each f1 In f.SubFoldersCall DoCount(f1)NextEnd SubThe File ObjectIn the FSO model, each file on a disk is represented by a File object.This object has methods and properties that you use to get information about the file and manipulate it.First, however, you need to create a File object associated with a specific disk file.Creating A File ObjectThere are two ways to create a File object.If you know the name and path of the file, you can use the FileSystemObject’s GetFile method.The code is as follows, assuming that fs is an instance of the FileSystemObject class:Dim fSet f = fs.GetFile(filespec)The filespec argument is the relative or absolute path to the file.An error occurs if filespec does not exist.Note that executing GetFile does not open the file or do anything else to it, but simply returns a File object linked to the file.TIP:  Relative Vs.Absolute PathsAn absolute path specifies complete information about the name and location of a file, including drive letter.For example, c:\data\ sales\march1998.dat is an absolute path.A relative path specifies a file location relative to the current default path.Sales\ march1998.dat is a relative path, specifying that the file MARCH1998.DAT in the subfolder Sales is the current default folder.If, and only if, the default path is c:\data will the absolute and relative paths given here be equivalent.Another way to obtain a File object is from a Folder object’s Files collection.As you learned earlier in this chapter, you can create a Folder object for any subfolder on a disk, and the Folder object contains a Files collection containing one File object for each file in the folder.You can write code to iterate through the collection, looking for one or more files that meet a specified criterion.For example, the following code creates an array of File objects containing all the DLL files in the application’s current path:Dim fs, f, f1, filelist()Dim i As Integer, j As Integeri = 0ReDim filelist(0)Set fs = CreateObject(“Scripting.FileSystemObject”)Set f = fs.GetFolder(App.Path)For Each f1 In f.FilesIf LCase(Right(f1.Name, 3)) = “dll” Theni = i + 1ReDim Preserve filelist(i)Set filelist(i) = f1End IfNextIf i > 0 ThenFor j = 1 To iDebug.Print filelist(j).NameNextEnd IfWorking With File ObjectsOnce you create a File object, you have access to all the properties of the file.You can also use the object’s methods for certain types of file manipulation.Let’s look at the methods first, listed in Table 14.4.The File object’s properties are listed in Table 14.5.Finally, the Attributes property provides information about the file’s attributes, such as whether it is read-only or a system file.The single value returned by the Attributes property is a composite of the individual attribute values, as shown in Table 14.6.This table also indicates which of the individual attributes are read/write and which are read-only.PreviousTable of ContentsNext |   |   |   |   | Use of this site is subject to certain ,All rights reserved.Reproduction whole or in part in any form or medium without express written of EarthWeb is prohibited.Read EarthWeb's privacy statement [ Pobierz całość w formacie PDF ]
  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • aceton.keep.pl
  • 
    Wszelkie Prawa Zastrzeżone! Kawa była słaba i bez smaku. Nie miała treści, a jedynie formę. Design by SZABLONY.maniak.pl.