473,394 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,394 developers and data experts.

Microsoft Scripting Runtime #3

ADezii
8,834 Expert 8TB
This is the 3rd in a series of Tips dealing specifically with the Microsoft Scripting Runtime Library. In this Tip, we'll show you how to return specific Properties relating to Files, as well as various Methods to Copy, Move, and Delete them. The code is self explanatory, so I'll jump right in:
Expand|Select|Wrap|Line Numbers
  1. Dim fso As FileSystemObject, fil As File
  2. 'Set fso = New Scripting.FileSystemObject    OR
  3.  
  4. Set fso = CreateObject("Scripting.FileSystemObject")
  5.  
  6. Set fil = fso.GetFile("C:\Windows\System32\Calc.exe")
  7.  
  8. Debug.Print "File Created on: " & fil.DateCreated
  9. Debug.Print "File Size: " & FormatNumber(fil.Size, 0) & " bytes"
  10. Debug.Print "File Drive: " & fil.Drive
  11. Debug.Print "File Name: " & fil.Name    'OR
  12. Debug.Print "File Name: " & fso.getFileName(fil)
  13. Debug.Print "File Last Modified: " & fil.DateLastModified
  14. Debug.Print "File Last Accessed: " & fil.DateLastAccessed
  15. Debug.Print "File Parent Folder: " & fil.ParentFolder
  16. Debug.Print "File Type: " & fil.Type
  17. Debug.Print "File Path: " & fil.path
  18. Debug.Print "File Short Name: " & fil.ShortName
  19. Debug.Print "File Short Path: " & fil.ShortPath
  20. Debug.Print "File Extension: " & fso.GetExtensionName(fil)
  21. Debug.Print "File Version: " & fso.GetFileVersion(fil)
  22.  
  23. 'To Copy a File (Copy C:\Windows\System32\Calc.exe ==> C:\Dell\Copy.exe)
  24. fil.Copy ("C:\Dell\Copy.exe")       'OR
  25. fso.CopyFile "C:\Windows\System32\Calc.exe", "C:\Dell\Copy.exe", True
  26.  
  27. 'To Delete a File (C:\Dell\IP.txt)
  28. Set fil = fso.GetFile("C:\Dell\IP.txt")
  29. fil.Delete True     'OR
  30. fso.DeleteFile "C:\Dell\IP.txt", True
  31.  
  32. 'To Move a File (C:\Dell\Move_From.txt ==> C:\Test\Move_To.txt
  33. Set fil = fso.GetFile("C:\Dell\Move_From.txt")
  34. fil.Move "C:\Test\Move_To.txt"      'OR
  35. fso.MoveFile "C:\Dell\Move_From.txt", "C:\Test\Move_To.txt"
File Properties OUTPUT:
Expand|Select|Wrap|Line Numbers
  1. File Created on: 9/11/2007 2:18:54 PM
  2. File Size: 114,688 bytes
  3. File Drive: C:
  4. File Name: calc.exe
  5. File Name: calc.exe
  6. File Last Modified: 8/4/2004 5:00:00 AM
  7. File Last Accessed: 2/15/2008 11:30:31 AM
  8. File Parent Folder: C:\WINDOWS\system32
  9. File Type: Application
  10. File Path: C:\WINDOWS\system32\calc.exe
  11. File Short Name: Calc.exe
  12. File Short Path: C:\Windows\System32\Calc.exe
  13. File Extension: exe
  14. File Version: 5.1.2600.0
Feb 15 '08 #1
0 5391

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: MatthewRoberts | last post by:
Howdy All, I am having difficulty with two-way communication across AppDomains in an attempt to dynamically script applications. Everything works as expected, except when using ByRef parameters....
0
by: fiona | last post by:
Catalyst Releases Scripting Editions of SocketTools Client and server-side development for Active Server Pages and PHP. Yucca Valley, CA, May 25, 2005 - Catalyst Development Corp...
17
by: Karl Irvin | last post by:
To use the Textstream object, I had to set a Reference to the Microsoft Scripting Runtime. This works good with A2000 Is the Scripting Runtime included with A2002 and A2003 so the Reference...
1
by: Karl Irvin | last post by:
To use the Textstream object, I had to set a Reference to the Microsoft Scripting Runtime. This works good with A2000 Is the Scripting Runtime included with A2002 and A2003 so the Reference...
14
by: frostalicious | last post by:
Used VB.NET (on my client PC) to convert VB6 executable to .NET executable. Placed the .exe file on a network drive on my server. From client, ran .NET Wizards "Trust an Assembly" to make the...
1
by: PaulieS | last post by:
Hi all. Am migrating a customer from IIS5 on W2K server to IIS6 on W2K3. Zipped all the websites and unzipped them to the identical locations on new server. Used IISMT to migrate metabase. ...
7
ADezii
by: ADezii | last post by:
The next series of Tips will involve the Microsoft Scripting Runtime Library (Scrrun.dll). This Library is, in my humble opinion, one of the most useful and practical Libraries ever created. With the...
0
ADezii
by: ADezii | last post by:
This is the 2nd Tip in a series of Tips on the Microsoft Scripting Runtime Library. The 1st Tip related to Drives, while this Tip will concentrate on the Folders (Directories) in your PC and various...
0
ADezii
by: ADezii | last post by:
This is the last in a series of Tips involving the Microsoft Scripting Runtime Library and deals with creating, opening, writing to, reading from, and closing Text Files via this Library. At this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.