|
-
Mar 29th, 2004, 04:40 AM
#1
Thread Starter
Junior Member
Resetting Filecursor(?)
Hello all,
I want to open a file through the FileOpen method, then read through all the lines, making a count for them with an integer and then I want to reset the cursor back to the beginning of the file. This is what my initial code looks like:
Code:
Dim FilePath As String
Dim cntLines As Integer
Dim strLine As String
FileOpen(1, FilePath, OpenMode.Input)
Do Until EOF(1)
strLine = LineInput(1)
cntLines += 1
Loop
Now after that, I want to NOT close the file, but reset the cursor back to the beginning of the file and read through the file AGAIN, only this time I use strLine to grab the data from it (txt file)
Any suggestions on how to do this?
Thanks in advance,
c(_)
-
Mar 29th, 2004, 12:04 PM
#2
Sleep mode
FileStream has Position method that sets the position where reading starts . You just need to set it to 0 .
-
Mar 31st, 2004, 02:01 AM
#3
Thread Starter
Junior Member
Thank you for your reply.
Sorry that my answer is this late, but it has been hectic here...
Anyways, I'm trying to prevent using FileStream since this class has a wrong way of handling foreign characters such as î, è etc.
I was hoping to do this with FileOpen, FileClose... Is there a way?
Thanks in advance,
c(_)
-
Mar 31st, 2004, 01:24 PM
#4
Hi.
The stream is not the one responsable for converting your characters wrong.
I think your problem is with the ASCiiEncoding.GetString function.
At least it's the case with danish ÆØÅ.
You have to instantiate a new encoding based in the codepage you need. In danish I would use :
VB Code:
Dim Enc As System.Text.Encoding = System.Text.Encoding.GetEncoding(1252)
MyString=EncGetString(MyBytes)
You just have to replace the 1252 with the codepage of your language (or the language used to create the file).
Then it should be ok.
I hope this helps, cause a stream IS the best way to do what you want.
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
Apr 1st, 2004, 01:43 AM
#5
Thread Starter
Junior Member
Thank you, I'll do that then.
Does anyone know how to obtain these codes?
It would be handy since I need to manipulate multiple country files (some files English, some French, some Dutch etc)
Thanks in advance (again!)
c(_)
-
Apr 1st, 2004, 06:49 AM
#6
Hi.
Go to Control Panel and open International.
On the "General" tab press "Advanced"
There you should see a list of codepages.
Note: This is from a Win2000 but I guess it look pretty much the same in XP.
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
Apr 1st, 2004, 07:04 AM
#7
Thread Starter
Junior Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|