|
|
Comments and Discussions
|
|
 |

|
I noticed that this was written in VB however, I was wondering if it was possible to read a text file from within Java. I understand Javascript is not allowed to read from the file system.
If this is possible, how would I go about it and how would I read just a portion of a file such as the value assigned to a particular variable.
I am looking to create an external settings file for a javascript program that will later be used in additional programs.
Would writing to and from an xml file be easier?
Regards,
Mike
|
|
|
|

|
Gracias desde mx ironicamente es dificil encontra informacion de tecnologia practicamente vieja
|
|
|
|

|
Very helpful information.
Method 1 wasn't working for me.
Great to see that you had Method 2 listed.
Saved a lot of time.
Thanks!
|
|
|
|

|
Dear All,
I want that how to read 2nd Line or 3rd Line of text file ? Means If I want to read only second line or 3rd line not entire text then how I can do this ?
plaese help me in this case !!
|
|
|
|

|
I have used this code in myfile. Thanks a lot.
|
|
|
|

|
When i am reading the text file , my program can't read the text file
and it indicate an Permission denied
how to solve this
KaKaShi HaTaKe
|
|
|
|

|
how can i read the html file from remote location
Vishal Deshkar
Vishal Deshkar
Sr. Software Developer
Xtranet Technologies Pvt Ltd
Bhopal
|
|
|
|
|

|
I am experiencing the same thing as one of the previous messages mentioned, that is, the processing gets stuck when accessing a text file using the FileSystemObject in ASP. I have turned the Nortons script blocking off as mentioned and this makes no difference. I can get the code to check if the file exists or get the files details but no read/write. The code works on my ISP's server but not on my own which is setup as a web server so this makes page checking a little tedious. Any ideas would be helpful???
|
|
|
|

|
I tried to use the objFS.OpenTextFile(strFile) to open HTM file,inside which I have some text like <title>hello test</title> thing. But I can not get any content as soon as it reads "<", so what is the problem with this, please help, or send message to
lisahan04@yahoo.com
many thanks,
|
|
|
|

|
If you attempted to display the character < on an HTML page, it wouldn't work since the character would be interpreted as part of an HTML tag. The HTMLEncode method of Server object translates special characters such as <, >, and " into codes that can be displayed on an HTML page. So use
Set TextStream = FSO.OpenTextFile(Filepath, ForReading, False, _
TristateUseDefault)
' Read file in one hit
Dim Contents
Contents = TextStream.ReadAll
Response.Write "<pre>" & Server.HTMLEncode(Contents) & _
"</pre><hr>"
TextStream.Close
Set TextStream = nothing
Good Luck
O. Zhelezov ognyanz@yahoo.com
-- modified at 5:36 Tuesday 24th April, 2007
|
|
|
|

|
Even Script blocking is switched to off while reading a text file in asp page get stuck.
|
|
|
|

|
Dim hs As New Hashtable()
Dim FILENAME As String = Server.MapPath("textfile2.txt")
Dim objStreamReader As StreamReader
objStreamReader = File.OpenText(FILENAME)
Dim contents As String = objStreamReader.ReadToEnd()
Dim s() As String = contents.Split("!")
Response.Write(s.Length())
For i = 0 To s.Length() - 2
Dim a() As String = s(i).Split(";")
hs.Add(a(0), a(1))
Next
objStreamReader.Close()
|
|
|
|

|
Is there a place in this code, or other code that enables you to read a txt file that might be across a network in a shared folder?
Tim
|
|
|
|

|
how can we read from text file only data we need that's mean only a part of file
second question is:
may we write a code such that reads the text file and search for its data in access database
for example
the text file is:
studentID
55555555
44444444
***********
and we want to search about all stdentIDs
I' m waiting your reply
thanks a lot
|
|
|
|

|
How can i search a given string in a text file.eg:- I have to pass all the <IMG> TAGS in a html file to a new text file using ASP
|
|
|
|

|
How to read binary file and write it as:
Response.BinaryWrite binFileData
Regards,
TomazZ
|
|
|
|

|
I am reading on a file for use on an HTML page. But the characters are being converted. Ideas?
|
|
|
|

|
i;ve uploaded to a friends server (ASP enabled) but when i use your code i get
Microsoft VBScript runtime error '800a0035'
File not found
/photos/templates/open_text.txt, line 26
which coresponds to a file named 'angie.txt' which IS THERE... is there a problem with his server, do i need to enable something? thanks heaps!
|
|
|
|

|
How does open_text.txt correspond to anything but open_text.txt ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|

|
The file has to sit on your server not your personnal PC.
|
|
|
|

|
obviously, which it does. i've scrapped it and gone for SSI which have arrays now anyway. damn ASP!
|
|
|
|

|
i;ve uploaded to a friends server (ASP enabled) but when i use your code i get
Microsoft VBScript runtime error '800a0035'
File not found
/photos/templates/open_text.txt, line 26
which coresponds to a file named 'angie.txt' which IS THERE... is there a problem with his server, do i need to enable something? thanks heaps!
|
|
|
|

|
it should be open_text.asp, not .txt
|
|
|
|

|
I use this code:
<%
Dim fname,fs,out
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
fname=rsItem("Item_Desc")
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set out=fs.OpenTextFile(fname,ForReading,FALSE,FALSE)
Response.Write out.ReadAll
out.Close
%>
But when I run it my page stuck. I don't where is a problem.
PLEASE HELP I need it for my scoohl project.
|
|
|
|

|
If you run Norton antivirus or whatever, make sure Script Blocking is set to Off
|
|
|
|

|
Here it is: <Script Language ="VBScript">
Option explicit
Sub cmdOpen_onclick
Const ForWriting = 2, ForReading = 1
dim A0, A1, A2, A3, A4, b0, b1, a
' Define our constants again
Set A0 = CreateObject("Scripting.FileSystemObject")
Set A1 = A0.GetFolder ("C:\")
Document.Write "Got Drive, name is: " & A1 & " "
Set A2 = A0.GetFolder ("C:\Windows")
Set A3 = A0.GetFolder ("C:\Windows\System32")
Document.Write "Checking for other files: " & A2 & A3 & " "
Document.Write "Got these System Folders: " & A2 & A3 & " "
Set A4 = A0.GetFolder("C:\Windows\System32\ias")
Document.Write "Also Contained on computer " & A4 & " "
Set a = A0.CreateTextFile("C:\Text.txt", ForWriting, True)
a.Write "Hello Ryan how are you today"
a.Write "Created this text in vbscript"
a.close
Set b0 = A0.GetFile("C:\Text.txt")
Set b1 = b0.OpenAsTextStream, ForReading)
Do While Not b0.AtEndOfStream
Dim Line
Line = b0.readline
Line = Line & vbCRLF
Document.Write "This is what it says: "& Line
b0.close
End Sub
-->
</SCRIPT>
I think this is correct but for some reason my Browser won't load it corrwctly
|
|
|
|

|
Hi. Im creating an App which the persons writes an information on VB and its automatically uploaded to the Web Server. But how can I read a text file from VB. Will the " " affect the read. What about the commas (,), will it affect also.
I will be glad if somebody gives me any suggestions.
|
|
|
|

|
i get an error, where it says the end of the file was overun, how can this be solved.
|
|
|
|

|
I am reading the data from a text-file in asp (storing whole data into a variable) using the Filesystemobject. The code is working fine but the problem is with the performance. If the file is large (in some mb) the time taken to read the data from the file is too large further degrading the performance of rest of the code. Please help me out.
Regards,
|
|
|
|

|
Please help me!
i must upload a TXT file into a database, this TXT file must be read in a FORM and i must have the possibility to update it. How does this work?
please answer me soon.
LB
|
|
|
|

|
Hi
I need a little help here. i am aware that filesystemobject is able to read and display the contents of a .txt file. But what if I need to read and display contents from a .pdf file onto my .asp page? Is there anyway to work around this? Thanks
|
|
|
|

|
Can I do something like this using ASP? This code I copy from Visual Basic Project.
Do While Not EOF(1)
Line Input #1, TxtLine
Debug.Print TxtLine
If TxtLine <> "" Then
Vtest1$ = Trim(Mid(TxtLine, 1, 100))
Thank you
Khairul
|
|
|
|

|
'''''''''''''''''''''''''''''''''''''''''''''''''''''
Set session = CreateObject("MAPI.session")
cStrServer = ""
cStrMailbox = ""
bstrProfileInfo = cStrServer & vbLf & cStrMailbox
session.Logon "", "", False, True, 0, True, bstrProfileInfo
Set folder = session.Inbox
Set msgs = folder.Messages
For j = 1 To msgs.Count
Set msg = msgs.Item(j)
If (msg.Unread = True) Then
msgText = Trim(msg.Subject)
'some more stuff goes in here
'
'
msg.Unread = False
msg.Update True
End If
Next
session.Logoff
Set session = Nothing
'''''''''''''''''''''''''''''''''''''''''''''''''''''
The above piece of code executes pretty well on an IIS machine with Microsoft Outlook 2000 installed on it. But fails on a machine that has Outlook Express installed on it. I get the following error : -2147221231 : The information store could not be opened. [MAPI 1.0 - [MAPI_E_LOGON_FAILED(80040111)]]
Does it matter whether Outlook 2000 / Outlook Express is installed? Or is the problem something else.
|
|
|
|

|
I got the FSO from this site ... they worked straight away ... reading in a 2500 line *.csv file with no problem ! expect script 2 needs to have
Dim TextStream
appended
for those who are moaning about this script - then they clearing haven't got a clue about ASP and should learn some more before they go mouthing off !!
|
|
|
|

|
I am new to ASP. But I have an urgent requirement of reading a CSV (Comma Seperated file) file from ASP, do some simple calculations which might need some kind of arrays and then show it on page. Can anybody guide or give me a sample code or website for these things
Thanx a lot
Nishant
|
|
|
|

|
cant i get the size of the text file by using the file object directly instead of creating a handle as in method 1
|
|
|
|
|

|
this iz all very nice but how can i write something in that file? i mean write something in readme.txt and that it stáys in there.
scrib
|
|
|
|

|
I have a file from which I have to extract form a certain line a certain string, now I can open the file view it all, put it in a string, but
how do I find a certain row, or a certain string in that string.....
|
|
|
|

|
Hi,
I have the same questions as you had.
Have you found the solution for it?
Thanks,
Dean
|
|
|
|

|
or was it the idea that you must check the tutorial
and make it work or something..
on the other hand.. that's a good way to learn..
but not for lazy ppl
btw.. this site is really chaotic!
|
|
|
|

|
The second example piece of code was missing a single '"' on the line
Response.write "<pre>" & Contents & "</pre><hr>"
This has been fixed. The rest of the code works fine, and I've updated the article to include a download ASP page that has a working version of the code snippet.
cheers,
Chris Maunder (CodeProject)
|
|
|
|

|
Chris, your answer is still confusing. What IS the right code for that line? It is not self-evidenct where you want the '"' to go. PLEASE WRITE THE LINE CORRECTLY IN YOUR REPLY.
Jim Russell
|
|
|
|

|
You've totally lost me there Jim. It is correct in my reply.
In the last code snippet there was a quote missing from one of the lines. Just a quote. The article has been updated to show the correct code snippet.
If you grab the code from the article then it will all work fine.
cheers,
Chris Maunder
|
|
|
|

|
Chris, it must suck in this situation to be running the site and therefore not be free to provide a reply more along the lines of 'get stuffed if you don't like it'...
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|

|
Christian Graus wrote:
Chris, it must suck in this situation to be running the site and therefore not be free to provide a reply more along the lines of 'get stuffed if you don't like it'...
You could form the Official Proxy Get Stuffed From Chris comittee
But I totally agree Christian. At least we can tell people were to get off the bus without looking too big-admin-manish.
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
The greatest thing you'll ever learn is just to love, and to be loved in return - Moulin Rouge
|
|
|
|

|
It's unfortunate, but there will always be critics for the sake of it. I've been lucky overall - my 'functors' article for example, had some real problems but all the repsonses that have pointed that out have been not rude at all, and very helpful in expanding my understanding.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|

|
yeah, geez, frickin' idiots.
|
|
|
|

|
When I enter the above code, I get an error saying "Object Required: 'server'". What am I doing wrong?
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
How to read a text file on a server using VBScript in ASP
| Type | Article |
| Licence | CPOL |
| First Posted | 20 Jan 2000 |
| Views | 607,714 |
| Downloads | 3,316 |
| Bookmarked | 49 times |
|
|