Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Other Programming > VBScript
|
VBScript For questions and discussions related to VBScript.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VBScript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 4th, 2004, 03:37 AM
Registered User
 
Join Date: Dec 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem in opening file

i am using an embedded vb application to open and display the contents of a file in a test box....


Dim fso As FileCtl.FileSystem
Dim Fil As FileCtl.File
Dim StrFullFileName As String
Dim sTheData As String

StrFullFileName = "\Program Files\text.txt"

Set fso = CreateObject("FileCtl.FileSystem")
Set Fil = CreateObject("FileCtl.File")

If Len(fso.Dir(StrFullFileName)) > 0 Then
Fil.Open StrFullFileName, fsModeInput, fsAccessRead
sTheData = Fil.LineInputString
 Text1.Text = sTheData
Else
MsgBox StrFullFileName & " does not exist."
End If

Set fso = Nothing
Set Fil = Nothing

but each time i run the program i am getting an error saying that the file do not exist ..this is my file location c:\Program Files\text.txt .Even if i give the full path i am getting the same error.....
please give a solution for this problem

thanks in advance

Reply With Quote
  #2 (permalink)  
Old December 5th, 2004, 10:35 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Does "FileCtl.FileSystem" contain any method that validates for FILE_EXISITENCE? If so try using that and check if the file exists. Or move the File to some other location, where the folder name doesn't contain SPACE within it(like that of "Program files").

Post here if that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
  #3 (permalink)  
Old December 6th, 2004, 03:03 AM
Registered User
 
Join Date: Dec 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Private Sub CmdLoad_Click()
File1.Open "\text.txt", fsModeInput
Text1.Text = File1.LineInputString
File1.Close
End Sub

Private Sub Command1_Click()
Dim Save As Variant
File1.Open "\text.txt", fsModeOutput
Save = Text1.Text
File1.LinePrint Save
File1.Close

the above codde is one which gives the same result as the previous one.....
i am having two problems here..
1)I want to open a file from the location i desire
2)Only the first line is retrived when i call back the file...i want the whole text content of the file

the above codes saves the content i typed in the text.txt in some default location and retrives it from there...
please help me
thanks in advance
Dawn

Reply With Quote
  #4 (permalink)  
Old December 6th, 2004, 04:20 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

You got to read the text file till the ENF OF STREAM and process it further. I am not sure what all methods does the object that you use for processing text files support. Check its documentation for more details.

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in opening excel file in MS Excel 2000 kallol Visual C++ 0 November 16th, 2007 05:48 AM
Opening file 80240210 Flash (all versions) 0 July 24th, 2007 06:08 PM
Problem in opening .doc file kumar_raj13 C# 1 March 13th, 2006 12:57 PM
file opening jain_mj Visual C++ 0 November 4th, 2005 10:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.