September 08 2010 07:51:22
Navigation
· Home
· Online Store
· Course Outlines (PDF Files)
· Sample Videos
· Contact Info
· Web Links
· Articles (Sample Code)

Other Videos
· WordPress (CMS)
· Joomla (CMS)
· Sharepoint

Other
· FAQ
· Search
Contribute to This Site
· Submit Link
· Get Benefitted Sites
No Competition
One of our so-called competitors offers under 6 hours of video training for a whopping $219 (choke, gasp, spew - you could hire a private tutor for that price). Did I mention that they ship their training on VHS tapes (remember those?). Check out our 'Course Outlines' link above. We offer a 2-days of training (15 hours) for $54 (2 CDs at $29 each). You watch our videos from a CD/ROM on your computer. We also include real-world lab/assignments in each course.
Articles: FSO - Read All
FSO - Read All
'==========================================================================
' NAME: FSO_File_ReadAll.vbs 
' AUTHOR: Neal Walters 
' DATE  : 3/26/2005
' http://VBScript-Training.com 
'==========================================================================
Option Explicit 

   Dim fso, myFolderName, objFolder, myFileName, objFile, myFQFilename, objTextStream, fileContents
   
   Set fso = CreateObject("Scripting.FileSystemObject")
   
   Dim forReading, forWriting, forAppending 
   forReading = 1 
   forWriting = 2 
   forAppending = 8

   myFolderName = "c:\Documents and Settings\nwalters\My Documents\Camtasia Studio\VBScript-Training2" 
   myFileName = "c:\rating.txt" 
   
   If fso.FolderExists(myFolderName) Then 
   
	   Set objFolder = fso.GetFolder(myFolderName) 
	   
	   WScript.Echo " Folder = " & objFolder.Name 
	   WScript.Echo " DateCreated = " & objFolder.DateCreated 
	   
	   Dim posLastSlash 
	   posLastSlash = InStrRev(myFolderName,"\") 
	   
	   
	   'dirname = "test"  len 4  dirname = "test\"  len 5 and slash in pos 5 
	   If posLastSlash = Len(myFolderName) Then 
	     'already ends with slash 
	     myFQFilename = myFolderName & myFileName
	   Else 
	     myFQFilename = myFolderName & "\" & myFileName
	   End If 
	   
	   WScript.Echo "FQ Filename=" & myFQFilename 
	   
	   If fso.FileExists(myFQFilename) Then 
		   Set objFile = fso.GetFile(myFQFilename) 
		   WScript.Echo "FileSize=" & objFile.Size 
		   
		   Set objTextStream = objFile.OpenAsTextStream (forReading) 
		   
		   fileContents = objTextStream.ReadAll 
		   
		   WScript.Echo "Length=" & len(fileContents) 
		   
		   WScript.Echo "Filename= " & myFileName 
		   WScript.Echo "FileContents = " & VbCrLf & fileContents 
	   Else 
	       WScript.Echo "File " & myFileName & " does not exist." 
	   End If 
	   
   Else 
   'If not exist - show the user the error 
       WScript.Echo "Folder does not exist: " & myFolderName 
   
   End If 


'==========================================================================
' NAME: FSO_File_ReadAll2.vbs 
' AUTHOR: Neal Walters 
' DATE  : 3/26/2005
' http://VBScript-Training.com 
'==========================================================================
Option Explicit 

   Dim fso, myFolderName, objFolder, myFileName, objFile, myFQFilename, objTextStream, fileContents
   
   Set fso = CreateObject("Scripting.FileSystemObject")
   
   Dim forReading, forWriting, forAppending 
   forReading = 1 
   forWriting = 2 
   forAppending = 8

   myFileName = "c:\Documents and Settings\nwalters\My Documents\Camtasia Studio\VBScript-Training2\FSO_Drive_Objects.txt" 
   
   Set objTextStream = fso.OpenTextFile(myFileName, forReading)
   fileContents =   objTextStream.ReadAll
   
   WScript.Echo fileContents
Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Order Now - View Products


Default Shipping:
Phone: 214-403-6006
Our Sites
Software Training
XML-Online-Training.com
Biztalk-Training.com
SharePoint-Training.com
DotNet-AddOns-Training.com
CMSTrainingVideos.com

Language
LanguageLovers.com
Render time: 0.08 seconds 432,182 unique visits