Ver Mensaje Individual
  #3 (permalink)  
Antiguo 07/05/2013, 16:28
Avatar de angel1993
angel1993
 
Fecha de Ingreso: octubre-2009
Mensajes: 752
Antigüedad: 15 años, 4 meses
Puntos: 22
Respuesta: Como crear un txt al ejecutar el formulario por primera ves?

Pues te recomiendo que uses system.io

Para crear un archivo si no existe...
Código vb:
Ver original
  1. If Not System.IO.File.Exists("C:\archivo.txt") Then
  2.             System.IO.File.CreateText("C:\archivo.txt").Close()
  3.         End If


Pero tienes que tener en cuenta que no necesitas "crearlo" para escribir.. hay una funciona AppendAllText está función sirve para agregar texto a un documento, de no existir lo crea automáticamente y agrega el texto, hay que tener cuidado, ya que el texto lo agrega, hay que comprobar que no exista porque podría escribir 2 veces lo mismo...
Código vb:
Ver original
  1. If Not System.IO.File.Exists("C:\archivo.txt") Then
  2.             System.IO.File.AppendAllText("C:\archivo.txt", "Usuario" & vbCrLf & "Contraseña")
  3.         End If
__________________
@angelxab Twiiter