Questions tagged [fso]

Object Model component on Windows systems that represents the local file system.

The FileSystemObject (FSO) Object Model is used to access the local file system. Among other things, it provides methods for

  • reading file properties
  • creating and deleting files and folders
  • reading from files

For a complete list, visit the documentation link below.

Questions using the tag are expected to relate to programming

Links:

118 questions
25
votes
5 answers

Using VBA to get extended file attributes

Trying to use Excel VBA to capture all the file attributes from files on disk, including extended attributes. Was able to get it to loop through the files and capture the basic attributes (that come from the file system): File Path File Name File…
Jim McKeeth
  • 38,225
  • 23
  • 120
  • 194
17
votes
3 answers

Issue with MoveFile method to overwrite file in Destination in vbscript?

I have a vbscript that I have written to move files from a source directory to a destination directory. The way the script works at the moment is that I have a mapping file which is read in (maps id's to folder type). Each file being moved begins…
user1587060
  • 187
  • 1
  • 1
  • 7
10
votes
2 answers

Read line per line a txt file with VBS

I'm trying this code: filename = "test.txt" listFile = fso.OpenTextFile(filename).ReadAll listLines = Split(listFile, vbCrLf) For Each line In listLines WScript.Echo line 'My Stuff Next Or this other: filename = "test.txt" Set fso =…
Mark
  • 684
  • 2
  • 9
  • 25
9
votes
3 answers

Access files with long paths (over 260)

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…
Gary Evans
  • 1,850
  • 4
  • 15
  • 30
5
votes
1 answer

How to solve the error User defined type not defined?

Below is a procedure to search folder for a folder like "requirements". When beginning to step through I receive an error message because of FileSystemObject: User defined type not defined What am I missing? Sub GetSubFolders() Dim f As Folder,…
t.mo
  • 253
  • 1
  • 4
  • 13
4
votes
2 answers

How does vbscript filesystemobject encode characters?

I have this vbscript code: Set fs = CreateObject("Scripting.FileSystemObject") Set ts = fs.OpenTextFile("tmp.txt", 2, True) for i = 128 to 255 s = chr(i) if lenb(s) <>2 then wscript.echo i …
david
  • 2,435
  • 1
  • 21
  • 33
4
votes
4 answers

How to read lines from a text file one by one with Power Point VBA code?

This code will read a line from a text file: set file = CreateObject("Scripting.FileSystemObject").OpenTextFile("c:\number.txt", 1) text = file.ReadLine MsgBox text How can I make it read repeatedly one line after another from the same file? I…
brilliant
  • 2,489
  • 8
  • 26
  • 28
3
votes
1 answer

FileSystemObject CopyFile with wildcard copies files with extensions longer than specified

In the source folder there are 3 files: a.csv b.csv a.csv_backup I would expect *.csv to copy a.csv and b.csv only, but it copies a.csv_backup as well. Code: Dim oFso As New Scripting.FileSystemObject oFso.CopyFile "c:\temp\*.csv" "d:\temp\"
coder
  • 4,121
  • 14
  • 53
  • 88
3
votes
1 answer

Faster way to dump immense text into array

I have a .txt with around 6gb of data. Fields delimited by semicolons. I need to check one of the fields line by line against a prebuild dictionary and if there is a match copy all the fields of the respective line into a 2 dimension…
Musicodelic
  • 93
  • 1
  • 12
3
votes
1 answer

VBscript WMI doesn't locate files, FSO does

I have two files weblogic.jar and weblogic.policy in C:\Weblogic\wlserver\server\lib. With the first method, the script finds them and displays the name of the file: Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder =…
Harald
  • 31
  • 3
3
votes
3 answers

Can I use FileSystemObject get a single file from a folder using its index?

If there is only one file in a folder, can I pick it up without knowing its name or iterating through the files in the folder? (The code is VBS, but it could be anything, the FSO is the interesting part here.) This didn't work for me: dim fso set…
vacip
  • 5,246
  • 2
  • 26
  • 54
3
votes
1 answer

Saving FileSystemObject as UTF

how can i save the file in utf-8? Dim FSO, File Set FSO = Server.CreateObject("Scripting.FileSystemObject") Set File = FSO.OpenTextFile(Path,2,true,-1) File.Write(xml1) File.Close Set File = Nothing Set FSO = Nothing
bob
  • 49
  • 1
  • 2
3
votes
2 answers

Is there a way to navigate backwards in a TextStream file?

I have started to use the fso object in order to overcome the 2GB limit of VBA. Everything looks satisfactory for my purposes, except that I can not find a way to go backwards in the textstream files. For going forward I have used read(no of chars)…
Demetres
  • 127
  • 2
  • 10
2
votes
1 answer

Permissions error on FSO DeleteFile/MoveFile

I'm trying to delete/move a file using classic asp fso but I'm getting this error: Microsoft VBScript runtime error '800a0046' Permission denied The file is located in c:\files\test\file.txt and ultimately I want to move it to…
greener
  • 4,989
  • 13
  • 52
  • 93
2
votes
1 answer

Writeline in VBA breaks with too long text

I am automating a web page extraction and writting the contents to a text (HTML) file. For that I set up a File System Object like this Dim myHTMLfilepath As String myHTMLfilepath = "C:\temp\MyFile.html" Dim fso As Object Set fso =…
Fabricio
  • 839
  • 9
  • 17
1
2 3 4 5 6 7 8