Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente bannato
    Registrato dal
    Aug 2001
    Messaggi
    894

    da un file txt. prendo il testo e lo inserisco in una variabile, come?

    mi date una mano?
    in piu vorrei conteggiare il numero di lettere (o caratteri)contenuti in questa variabile attraverso un'istruzione, ma quale?

  2. #2
    <%@ Import Namespace="System.IO" %>
    <%
    Response.write("Reading the content from the text file ASPNET.TXT
    ")

    ' create a stream reader object
    Dim streamreaderobj As StreamReader

    ' Declare a variable for holding the content read from the file
    Dim filecont As String

    ' Open the text file and assign it to streamreader object
    streamreaderobj = File.OpenText( "c:\aspnet.txt" )

    ' Read the content of the file line by line employing streamreaderobj
    ' Note that when filecont gets a value emptystring ("") it indicates end of file

    Do
    filecont = streamreaderobj.ReadLine()
    Response.Write( filecont & "
    " )
    Loop Until filecont = ""

    ' Close the streamreader object after the reading operation
    streamreaderobj.Close

    Response.write("
    Done with reading the content from the file aspnet.txt")
    %>

  3. #3
    Utente bannato
    Registrato dal
    Aug 2001
    Messaggi
    894
    il tuo codice e perfetto e funziona tranquillamente, invece il mio (preso dai manuali di apogeo) genera errori ripetuti:

    dim f as new File(Server.MapPath("testo.txt"))
    objReader = f.OpenText
    Response.Write(Strings.Chr(objReader.Read.ToEnd))
    objReader.Close


    l'errore e f as new file (non supportato da <%@ Import Namespace="System.IO" %> )

  4. #4
    Utente bannato
    Registrato dal
    Aug 2001
    Messaggi
    894
    :zamm:

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.