Ayuda, archivos ...
#1

Buenas a todos, me podrian ayudar con esto, como podria hacer lo siguiente: (es ke no utilizo mucho el include File y sus funciones y estoy medio dudoso) .

quiero crear una cantidad de archivos de textos y despues leerlos en un dialogo con listitem y ke cada item sea un archivo de texto (osea ke sea el nombre del archivo).

si me pueden ayudar se los agradezco mucho.
desde ya muchas gracias, saludos.
Reply
#2

Leer lнnea por lнnea ?
Reply
#3

Quote:
Originally Posted by zSuYaNw
View Post

no, archivo por archivo.
Reply
#4

Quote:
Originally Posted by OTACON
View Post

no, archivo por archivo.
Tienes que hacer un archivo (Allfiles.txt) que contiene su nombres ..
Reply
#5

hice esto, para crearl os archivos no hay problema, pero tengo problemas para leerlos .

pawn Code:
//para crear
    new texto[2][100], File:archivo;
    for(new index=1; index<20; index++) {
        format(texto[0],50, "/carpeta1/carpeta2/textos[%02d].txt", index);
        archivo = fopen(texto[0], io_write);
        if(archivo) {
            format(texto[1],50, "archivo [%02d] escrito con exito!.", index);
            fwrite(archivo, texto[1]);
            fclose(archivo);
        }
    }
   
    //para leer
    new texto[2][100], File:archivo;
    for(new index=1; index<20; index++) {
        format(texto[0],50, "/carpeta1/carpeta2/textos[%02d].txt", index);
        while(fread(archivo, texto[0]))  {
            format(archivo[1],50, "textos[%02d] \n", index);
            strcat(texto[0], texto[1]);
            ShowPlayerDialog(playerid, MENU_ID, DIALOG_STYLE_LIST, "Titulo", texto[0], "Seleccionar", "Cancelar");
        }
        fclose(archivo);
    }
Reply
#6

Para crear:

pawn Code:
static
        File: Arquivo,
        string[200],
        zstr[50]
    ;
   
    for(new i; i != 20; ++i){
        format(zstr, 50, "textos[%02d].txt", i);

        Arquivo = fopen(zstr, io_write);
       
        if(Arquivo){
            format(string, 200, "archivo [%02d] escrito con exito!.", i);
            fwrite(Arquivo, string);
        }
       
        fclose(Arquivo);
    }



Para Leer

pawn Code:
static

        File: Arquivo,
        zstr[100]
    ;
   
    for(new i; i != 20; ++i){
        format(zstr, 50, "textos[%02d].txt", i);
       
        if(fexist(zstr)){
            Arquivo = fopen(zstr, io_read);
           
            static
                sTe[100]
            ;
           
            while(fread(Arquivo, sTe)){
                printf("Archivo: %s - %s", zstr, sTe);
            }
        }
    }
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)