When i develop some application, i need to read file contents. And this code will help you to create it.
Public Function GetFileContents(ByVal FullPath As String) As StringDim strContents As StringDim fso As FileSystemObjectDim ts As TextStreamSet fso = CreateObject("Scripting.FileSystemObject")strContents = ""If fso.FileExists(FullPath) ThenSet ts = fso.OpenTextFile(FullPath)Do Until ts.AtEndOfStreamstrContents = strContents + ts.ReadLine + vbCrLfLoopts.CloseEnd IfGetFileContents = strContentsEnd Function
Have a nice days.
No comments:
Post a Comment