|
-
Nov 19th, 2000, 07:03 PM
#1
Using this:
Code:
Dim strTemp As String
Open "C:\Test.txt" For Binary Access Read As #1
strString = Input(FileLen("C:\Text.txt"), #1)
Close #1
It is incredibly slow. I tried using the get function, but it doesn't work.
Is there any faster way than this?
-
Nov 19th, 2000, 07:12 PM
#2
According to the kedamanologist , he would want you to use this way:
Code:
Dim buffer as String
Open File for Binary as #1
buffer = Space(LOF(1))
Get #1 , , buffer
Close #1
Text1 = buffer
-
Nov 19th, 2000, 09:41 PM
#3
That's what I did, Matt, but for some reason it just doesn't put anything into the string. Maybe it's the file I am trying to access...
-
Nov 20th, 2000, 02:18 AM
#4
Hyperactive Member
You may want to check out the CreateFile api.
td.
"One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig
[email protected]
"but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.
-
Nov 20th, 2000, 02:30 AM
#5
Maybe it didn't work because you're using strString instead of strTemp?
-
Nov 20th, 2000, 02:33 AM
#6
No no, that was just a typo. And that's the slow one too, I'm looking for a fast one (to open files of around 1 or 2 megs).
-
Nov 20th, 2000, 03:41 AM
#7
Well then, read data in parts. Not everything at once, read more when more is needed. I don't know what kind of program you're making but this is the fastest way.
-
Nov 20th, 2000, 05:24 AM
#8
Addicted Member
Are we talking about sequential files, like .txt, .htm and such?
In that case, you could use the RichTextBox and Text.Loadfile MyFileName, where MyFileName is a string containing the full path and name of your file (such as "C:\Windows\Textfile.txt")
I use it, and it takes only a few seconds for files as large as three of four Mb.
Try it!
Pentax
Wilhelm Tunemyr,
Swede in London
[email protected]
"Dort, wo man Bücher verbrennt, verbrennt man am Ende auch Menschen"
Heinrich Heine (1797-1856)
Pravda vítezi!
(Truth prevails!)
-
Nov 20th, 2000, 07:15 PM
#9
I sort of need to read the whole thing at once, because it looks for a certain part in the file, which seperates it from the rest. If I read the file in seperate parts, I might miss half of the seperator (which is 16 characters long).
This is really starting to puzzle me.
-
Nov 20th, 2000, 09:03 PM
#10
_______
<?>
this is kedaman's code as above and testing it, it works
find for me.
Code:
'Open a file in binary mode and read into a textbox or string
Dim sHolder As String
Dim intNum As Integer
Dim sFileName As String
Dim myString As String
'open for binary and read
sFileName = "C:\My Documents\MyFile.txt"
intNum = FreeFile
Open sFileName For Binary As intNum
sHolder = Space(LOF(1))
Get #1, , sHolder
Close intNum
myString = sHolder
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Nov 20th, 2000, 09:12 PM
#11
Re: <?>
Quite the same code as above Wayne, he said it didn't work . Works well for me though.
-
Nov 20th, 2000, 10:37 PM
#12
I still don't get it. It works fine with the input function, but when I use get it doesn't work.
Just another question, strings can hold up to (or around) 2 gigs can't they? or was it 2 megs?
-
Nov 20th, 2000, 10:47 PM
#13
transcendental analytic
Strings hold up 2 gigs, that's correct. 2^31 bytes.
There might be a problem with your file, first check if the length of file isn't 0, put a break before the get statement and type ?lof(1) in immediate window. That would show that your file is empty.
BTW, no error messages? The length of the string after get statement?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 20th, 2000, 10:50 PM
#14
The length of the file is around 2 megs, and I don't get any error messages. The length of the string is the length of the file, but it is all spaces (due to the statement "strTemp = Space(LOF(1))").
-
Nov 20th, 2000, 11:57 PM
#15
transcendental analytic
Hmm, that sounds very odd, and it works with input$? that really is strange. well theres another way though, not sure if it would change the situation but may be worth a try.
Code:
Dim buffer() as byte
Open File for Binary as #1
Get #1 , , buffer
Close #1
Text1 = strconv(buffer,vbunicode)
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 21st, 2000, 02:57 AM
#16
No, it must be the get function that doesn't work all together. Maybe if I reinstall VB, it might work. Problem is it takes too long and I will probably have to restart my computer 1,000 times, just like when installing Windows.
Why does Windows need to restart lots of times when you install it. It does one little job 'Oh! Have to restart.' Then of course they have the dialog where the only button is 'restart' and if you don't push it the computer will restart in 15 seconds anyway. You'd think it would do everything, and then restart, but it does everything seperately. Must be Microsoft making little things look difficult.
-
Nov 21st, 2000, 09:12 AM
#17
Addicted Member
Just repeating...
If you put a RichTextBox on the form, and makes it invisible, you can load the file into it and then into a string. Like this:
Code:
Dim filename, 2megs As String
Text1.Visible = False
filename = "C:\Windows\MyBigFile.txt" 'or whatever
Text1.Loadfile filename, rtf 'I am not really sure about
'rtf, test with and without
2megs = Text1.Text
'Do whatever you want with your string, instr and so on...
Try it out!
Pentax
Wilhelm Tunemyr,
Swede in London
[email protected]
"Dort, wo man Bücher verbrennt, verbrennt man am Ende auch Menschen"
Heinrich Heine (1797-1856)
Pravda vítezi!
(Truth prevails!)
-
Nov 21st, 2000, 11:03 AM
#18
transcendental analytic
Well Dreamlax, i'm almost sure you don't even have to restart after reinstalling vb, i had to do it once and it never asked for restart. BTW, you can abort the restarting process if you are fast enough, open notepad type a letter. It will ask you to save and press cancel 
It's very strange that Get statement is failing while input$ is working, usually the problem is the reverse case. Try pentax sample to
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 21st, 2000, 04:46 PM
#19
Addicted Member
I checked...
The correct commandline is
Code:
Text1.LoadFile filename
You shouldn't use rtfText afterwards (while if you want to save text to a file you shall use Text1.SaveFile filename, rtfText).
Good luck,
Pentax
Wilhelm Tunemyr,
Swede in London
[email protected]
"Dort, wo man Bücher verbrennt, verbrennt man am Ende auch Menschen"
Heinrich Heine (1797-1856)
Pravda vítezi!
(Truth prevails!)
-
Nov 21st, 2000, 08:09 PM
#20
Pentax's code works OK, except when opening files like JPEGs. It displays the file header, and a little bit of whats inside, but it cuts it of (truncates) after about 64 bytes.
-
Nov 22nd, 2000, 08:16 AM
#21
transcendental analytic
I guess RTB's are sensitive to either EOFmarks or nullchars. The earlier is more probable, JPEG's are stored binary so it's very likely that it will occur. BTW, can i have a look at the file?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 22nd, 2000, 08:42 AM
#22
No problem, or is there. Hotmail doesn't let you have e-mail attachments over 1 meg or something don't they (and you have a hotmail address, well the one on your signitaure anyway)?
-
Nov 22nd, 2000, 08:48 AM
#23
transcendental analytic
Well yeah i know hotmail can do something really annoying when i get over 2M. Do you have ICQ or can you upload it somewhere?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 22nd, 2000, 04:57 PM
#24
New Member
Try this (though it's a bit late)
Dim buffer (1 to 1000) As Byte
Dim numFile
numFile = FreeFile
Open "patapim.file" For Random as #numfile Len=Len(buffer)
So that you can read with a buffer of 1000 bytes.
It's great knowing Quick Basic!
-
Nov 22nd, 2000, 06:01 PM
#25
Kedaman, you can download the file here. It's not the JPEG file, but it's one which I am also have trouble loading.
Dreamlax Entertainment Video
That's just a little video I put at the beginning of some other videos.
-
Nov 23rd, 2000, 02:53 PM
#26
transcendental analytic
seems to be no problem with the file, the first 100 bytes:
RIFF2ó AVI LIST~" hdrlavih8 @ ð LIST” strl
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 24th, 2000, 03:19 PM
#27
Addicted Member
Hmmm.
I tested to open a Jpeg and save as another name, and it worked (When opening the file the picture displayed allright).
But maybe that's not the problem?
Wilhelm Tunemyr,
Swede in London
[email protected]
"Dort, wo man Bücher verbrennt, verbrennt man am Ende auch Menschen"
Heinrich Heine (1797-1856)
Pravda vítezi!
(Truth prevails!)
-
Nov 28th, 2000, 12:44 PM
#28
Hyperactive Member
seems like the right topic
Anybody know how i can scan a folder of files and collect the bytesize of all in the directory.. do i use FileLen?
Many Thanks
-
Nov 28th, 2000, 02:23 PM
#29
transcendental analytic
Yes, you loop trough all files using dir function and add up filelen into sum:
Code:
dim a$,sum&
a=dir(path)
do while len(a)
sum=sum+filelen(a)
a=dir
loop
debug.?sum
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 29th, 2000, 05:35 AM
#30
Hyperactive Member
mmmH
Nothing happens, whats wrong with this, a =0 so exits.
destPath = "d:\" + "releaseCD" + "\" + "netVESPA" + "\" + "5.2.0.0" + "\" + "NTT" + "\" + "Documentation" + "\" + "Manuals" + "\"
VALID PATH WITH FILES IN.
a = Dir(destPath)
Do While Len(a)
result = result + FileLen(a)
a = Dir
Loop
Debug.Print result
-
Nov 29th, 2000, 05:38 AM
#31
Hyperactive Member
ignore last message this is problem
I get the message file not found at:
result = result + filelen(a)
the a is equal to the first file but wont proceed?
-
Nov 29th, 2000, 11:07 AM
#32
transcendental analytic
a should be declared as string, to contain the filename, i'm sorry if that appeared unclear Dir returns the first file only if you specify a new path, otherways it returns the next file until theres no files left, then it returns a nullstring, and therefore the loop ends.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 29th, 2000, 11:35 AM
#33
Hyperactive Member
HERE IT IS. CHEERS PATH NEEDED APPEND TO FILE
Dim result&
Dim a$
destPath = filePaths.CDImageLocation + "\" + curRecord.ProductDIR + "\" + curRecord.versionText + "\" + curRecord.CustomerID + "\" + "Documentation" + "\" + "Manuals" + "\"
'destPath = "e:\" + "releaseCD" + "\" + "netVESPA" + "\" + "5.2.0.0" + "\" + "NTT" + "\" + "Documentation" + "\" + "Manuals" + "\"
a = Dir(destPath)
Do While Len(a)
result = result + FileLen(destPath + a)
a = Dir
Loop
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
|