using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace AplicacionDePrueba
{
public partial class Form1 : Form
{
public bool validname;
public Form1()
{
InitializeComponent();
//Chequeo si hay tracelog
string path = System.IO.Directory.GetCurrentDirectory();
if (System.IO.Directory.Exists(path+"\\TraceLog"))
{
string fecha = DateTime.Now.ToString();
string fecha1 = fecha.Replace("/", "");
string fecha2 = fecha1.Replace(":", "");
string fecha3 = fecha2.Replace(" ","");
System.IO.Directory.Move(path+"\\TraceLog", path+"\\TraceLog"+fecha3);
}
System.IO.Directory.CreateDirectory(path+"\\TraceLog");
validname = false;
MinimizeBox = false;
MaximizeBox = false;
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text != "")
{
string nombre = textBox1.Text.ToString();
if (!ContainsForbidden(nombre))
{
//if name already exists or not, this cant be checked here, so..
validname = true;
}
else
{
MessageBox.Show("El nombre contiene caracteres invalidos");
}
}
else
{
MessageBox.Show("El nombre no puede ser vacio");
}
if (validname)
{
Form2 form2 = new Form2();
form2.ShowDialog();
}
else
{
textBox1.Text = "";
}
}
public static bool ContainsForbidden(string text)
{
return text.IndexOfAny("/\\?*<>|:\"".ToCharArray()) >= 0;
}
}
}
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario