filesystemobject

reading and writing a csv file using FileSystemObject

末鹿安然 提交于 2019-11-28 09:33:11
Is it possible to read and write csv files using FileSystemObject in VBA? It certainly is. Basic syntax such as Set objFSO = CreateObject("scripting.filesystemobject") 'create a csv file Set objTF = objFSO.createtextfile("C:\test\myfile.csv", True, False) 'open an existing csv file with writing ability Set objTF = objFSO.OpenTextFile("C:\test\myfile.csv", 8) will create/open a CSV with FSO . The CSV can then be modified by writing to it While this is an Excel example you can use the same technique to write records from Outlook, Access, Word etc Const sFilePath = "C:\test\myfile.csv" Const

Directory file size calculation - how to make it faster?

大憨熊 提交于 2019-11-28 05:56:55
Using C#, I am finding the total size of a directory. The logic is this way : Get the files inside the folder. Sum up the total size. Find if there are sub directories. Then do a recursive search. I tried one another way to do this too : Using FSO ( obj.GetFolder(path).Size ). There's not much of difference in time in both these approaches. Now the problem is, I have tens of thousands of files in a particular folder and its taking like atleast 2 minute to find the folder size. Also, if I run the program again, it happens very quickly (5 secs). I think the windows is caching the file sizes. Is

Access files with long paths (over 260)

两盒软妹~` 提交于 2019-11-28 00:37:09
问题 I'm using Microsoft Scripting Runtime (FSO) to parse folders and produce a list of all of its contents, the folders are on a network and resultant paths end up longer than 260. The minimum code I have is as below:- Private Sub ProcessFolder(ByVal StrFolder As String) Dim Fl As File Dim Fldr As Folder Dim RootFldr As Folder Set RootFldr = FS.GetFolder(StrFolder) For Each Fl In RootFldr.Files Debug.Print Fl.Path Next For Each Fldr In RootFldr.SubFolders DoEvents ProcessFolder Fldr.Path Next Set

Error: ActiveX Component Can't Create Object Scripting.FileSystemObject

丶灬走出姿态 提交于 2019-11-27 23:07:55
I have a simple vbs-file on my drive c: with following content: Set objShell = CreateObject("Scripting.FileSystemObject") When I'm trying to launch it, I get error c:\fso.vbs(1, 1) Microsoft VBScript runtime error: ActiveX component can't create object: 'Scripting.FileSystemObject' I tried to login as admin and execute wscript -regserver , but didn't help. Can someone help me please? byte Assuming you are logged in as Admin, please have a look in registry for Scripting.FileSystemObject under HKCR. If you can not find this PROGID then you are missing the required files or the component is

Loop through ALL files in a folder based on 'Last Modified Date'

泄露秘密 提交于 2019-11-27 20:55:12
I need to loop through the files in a given folder in descending order of 'Last Modified Date'. In the first iteration of the loop I need to be able to open the most recently modified file for reading and close it. In the second iteration, I need to be able to open the 2nd most recently updated file for reading and close it etc. Is there a built in method that allows a FileSystemObject to sort the files or do we absolutely have to write custom sorting routine? If we have to go with a custom sorting routine, is it possible to write this without having multiple functions? i.e. all code in the a

Order of Files collection in FileSystemObject

霸气de小男生 提交于 2019-11-27 15:45:12
In VBScript, I want to get a list of files in a folder ordered by creation date. I saw that in order to do that I will need to either use a record set (seems like an overkill to me) or sort the collection myself (I think I can avoid it and I want my code to be shorter). Since I am the one creating the files, I create them with names that begin with the date (yyyy_mm_dd) so I though that if I can get the files at least ordered by name then I'm all set. Unfortunately, the MSDN documentation of the Files collection from FileSystemObject doesn't say anything about the order of the collection. Does

reading and writing a csv file using FileSystemObject

无人久伴 提交于 2019-11-27 02:59:28
问题 Is it possible to read and write csv files using FileSystemObject in VBA? 回答1: It certainly is. Basic syntax such as Set objFSO = CreateObject("scripting.filesystemobject") 'create a csv file Set objTF = objFSO.createtextfile("C:\test\myfile.csv", True, False) 'open an existing csv file with writing ability Set objTF = objFSO.OpenTextFile("C:\test\myfile.csv", 8) will create/open a CSV with FSO . The CSV can then be modified by writing to it While this is an Excel example you can use the same

Error: ActiveX Component Can't Create Object Scripting.FileSystemObject

时光怂恿深爱的人放手 提交于 2019-11-26 23:15:50
问题 I have a simple vbs-file on my drive c: with following content: Set objShell = CreateObject("Scripting.FileSystemObject") When I'm trying to launch it, I get error c:\fso.vbs(1, 1) Microsoft VBScript runtime error: ActiveX component can't create object: 'Scripting.FileSystemObject' I tried to login as admin and execute wscript -regserver , but didn't help. Can someone help me please? 回答1: Assuming you are logged in as Admin, please have a look in registry for Scripting.FileSystemObject under

Loop through ALL files in a folder based on 'Last Modified Date'

耗尽温柔 提交于 2019-11-26 20:29:51
问题 I need to loop through the files in a given folder in descending order of 'Last Modified Date'. In the first iteration of the loop I need to be able to open the most recently modified file for reading and close it. In the second iteration, I need to be able to open the 2nd most recently updated file for reading and close it etc. Is there a built in method that allows a FileSystemObject to sort the files or do we absolutely have to write custom sorting routine? If we have to go with a custom

Order of Files collection in FileSystemObject

我的梦境 提交于 2019-11-26 14:48:08
问题 In VBScript, I want to get a list of files in a folder ordered by creation date. I saw that in order to do that I will need to either use a record set (seems like an overkill to me) or sort the collection myself (I think I can avoid it and I want my code to be shorter). Since I am the one creating the files, I create them with names that begin with the date (yyyy_mm_dd) so I though that if I can get the files at least ordered by name then I'm all set. Unfortunately, the MSDN documentation of