tutor2000 Posted May 31, 2004 Posted May 31, 2004 Anyone know how to read a file line in vbs? I don't even understand how to open the file yet. I need it for an autoitx project and autoitx cannot read file lines only ini's Rick
condoman Posted May 31, 2004 Posted May 31, 2004 Here is some sample code:Dim fso, f1, f2, sfile1 = "C:\WSH\testfile.txt"file2 = "C:\WSH\@ph\testfile.txt"file3 = "C:\WSH\testfile2.txt"Set fso = CreateObject("Scripting.FileSystemObject")Set f1 = fso.CreateTextFile(file1, True)WScript.StdOut.Writeline "Writing file"' Write a line.f1.Write ("This is a test.")' Close the file to writing.f1.CloseWScript.StdOut.WriteLine "Moving file to c:\tmp"' Get a handle to the file.Set f2 = fso.GetFile(file1)' Move the file.f2.Move (File2)WScript.StdOut.WriteLine "Copying file to c:\temp"' Copy the file to \temp.f2.Copy (file3)WScript.StdOut.WriteLine "Deleting files"' Get handles to files' current location.Set f2 = fso.GetFile(file2)Set f3 = fso.GetFile(file3)' Delete the files.f2.Deletef3.DeleteWScript.StdOut.WriteLine "All done!"
tutor2000 Posted May 31, 2004 Author Posted May 31, 2004 Thanks bradah After I look it over being a newbie to vbscript I'll probbly have more questions Rick
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now