File System in VB6

How to use FSO in VB6

Page 1 of 1

7 Replies - 20383 Views - Last Post: 24 August 2006 - 08:18 AM Rate Topic: -----

#1 jolsson1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 22-August 06

File System in VB6

Posted 22 August 2006 - 06:17 PM

Hi, I really can't get my head around FSO in VB6. I just want to open a file (e.g. "C:\File.txt" and put it in a text box. Would someone be able to give me the exact code to do this? Many thanks.
Is This A Good Question/Topic? 0
  • +

Replies To: File System in VB6

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: File System in VB6

Posted 22 August 2006 - 07:36 PM

Take a look here:

http://msdn.microsof...latingFiles.asp

Moved to VB forum
Was This Post Helpful? 0
  • +
  • -

#3 Louisda16th  Icon User is offline

  • dream.in.assembly.code
  • member icon

Reputation: 15
  • View blog
  • Posts: 1,967
  • Joined: 03-August 06

Re: File System in VB6

Posted 23 August 2006 - 05:46 AM

file system objects basically allow u to manipulate files(i had a problem understandin em too :P )
first u need to create a FSO, then read from it like this:
dim fobject, file
Set fobject = CreateObject("Scripting.FileSystemObject")
Set file = fobject.OpenTextFile("C:\File.txt", 1) '1 stands for reading, 2 stands for writing
Text1.Text = file.ReadAll
file.Close



hope this helps u out :)

This post has been edited by Louisda16th: 24 August 2006 - 12:32 AM

Was This Post Helpful? 0
  • +
  • -

#4 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: File System in VB6

Posted 24 August 2006 - 03:53 AM

View PostLouisda16th, on 23 Aug, 2006 - 06:16 PM, said:

dim fobject, file


Declaring the variables this way will result in them being created as Variants.
This Declaration statement makes things clear for us as well as the compiler:
Dim fobject as Object, file as Object

Was This Post Helpful? 0
  • +
  • -

#5 Louisda16th  Icon User is offline

  • dream.in.assembly.code
  • member icon

Reputation: 15
  • View blog
  • Posts: 1,967
  • Joined: 03-August 06

Re: File System in VB6

Posted 24 August 2006 - 07:03 AM

:) Im posting this question in this thread since its kinda related.
how can u set file attributes like hidden, readonly thru FSO??
Was This Post Helpful? 0
  • +
  • -

#6 Nevermalchik  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 12
  • Joined: 23-August 06

Re: File System in VB6

Posted 24 August 2006 - 07:28 AM

View PostLouisda16th, on 24 Aug, 2006 - 07:03 AM, said:

:) Im posting this question in this thread since its kinda related.
how can u set file attributes like hidden, readonly thru FSO??



Example:
Dim FSO as New FileSystemObject
Dim flFile as File

SET flFile =  FSO.GetFile("c:\Test.zip")
flFile.Attributes = Hidden


This post has been edited by Nevermalchik: 24 August 2006 - 09:23 AM

Was This Post Helpful? 0
  • +
  • -

#7 Louisda16th  Icon User is offline

  • dream.in.assembly.code
  • member icon

Reputation: 15
  • View blog
  • Posts: 1,967
  • Joined: 03-August 06

Re: File System in VB6

Posted 24 August 2006 - 07:50 AM

View PostNevermalchik, on 24 Aug, 2006 - 07:58 PM, said:

View PostLouisda16th, on 24 Aug, 2006 - 07:03 AM, said:

:) Im posting this question in this thread since its kinda related.
how can u set file attributes like hidden, readonly thru FSO??



Example:
Dim FSO as New FileSystemObject
Dim flFile as Files

SET flFile = FSO.GetFile("c:\Windows\")

you can do a loop, or search for particulare file...

flfile.item(0).attributes = <a enum will appear>


Is it possible to do this while creating the file itself. for example:
Dim User As Object, FSO As New FileSystemObject
Set User = FSO.CreateTextFile("C:\Hello.txt", True)
	User.Write "Hello"
	User.Close



what can u do here.
What i tried is declaring user as File. but the compiler says dat the Write Method or data member not found. If i declare User as object then the attribute property doesnt exist.
Was This Post Helpful? 0
  • +
  • -

#8 Louisda16th  Icon User is offline

  • dream.in.assembly.code
  • member icon

Reputation: 15
  • View blog
  • Posts: 1,967
  • Joined: 03-August 06

Re: File System in VB6

Posted 24 August 2006 - 08:18 AM

View PostNevermalchik, on 24 Aug, 2006 - 07:58 PM, said:

View PostLouisda16th, on 24 Aug, 2006 - 07:03 AM, said:

:) Im posting this question in this thread since its kinda related.
how can u set file attributes like hidden, readonly thru FSO??



Example:
Dim FSO as New FileSystemObject
Dim flFile as File

SET flFile = Set bnkFile = FSO.GetFile("c:\Test.zip")
flFile.Attributes = Hidden


works. Thanx :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1