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;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void button1_Click(object sender, EventArgs e)
{
folderBrowserDialog1.ShowNewFolderButton = true;
folderBrowserDialog1.ShowDialog();
String pfad = folderBrowserDialog1.SelectedPath;
String verzeichnis = "D:\\test.txt";
StreamWriter sw = new StreamWriter(verzeichnis, true);
string zwischenspeicher = pfad + "\\" + ";";
MessageBox.Show(zwischenspeicher);
sw.WriteLine(zwischenspeicher);
sw.Close();
}
private void Form1_Load(object sender, EventArgs e)
{
String pfad = "D:\\test.txt";
StreamReader sr = new StreamReader(pfad);
string Line = sr.ReadToEnd();
string[] split = Line.Split(new Char[] { ';' });
foreach (string s in split)
{
if (s.Trim() != "")
this.listBox1.Items.Add(s);
}
sr.Close();
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
ListBoxItem item = sender as ListBoxItem;
string listboxitem = listBox1.SelectedItem.ToString();
MessageBox.Show(listboxitem);
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void label3_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show(Convert.ToString(listBox1.SelectedItem));
int jahrvon = Int32.Parse(textBox1.Text);
int monatvon = Int32.Parse(textBox2.Text);
int tagvon = Int32.Parse(textBox3.Text);
int jahrbis = Int32.Parse(textBox6.Text);
int monatbis = Int32.Parse(textBox5.Text);
int tagbis = Int32.Parse(textBox4.Text);
System.DateTime date2 = new System.DateTime(jahrbis, monatbis, tagbis);
System.DateTime date3 = new System.DateTime(jahrvon, monatvon, tagvon);
// diff2 gets 55 days 4 hours and 20 minutes.
System.TimeSpan diff2 = date2 - date3;
// MessageBox.Show(Convert.ToString(date2));
// MessageBox.Show(Convert.ToString(date3));
// MessageBox.Show(Convert.ToString(diff2.Days));
//int differenztag = diff2.Days;
//bool OrdnerExisitiert = System.IO.Directory.Exists(Convert.ToString(listBox1.SelectedItem));
//MessageBox.Show(Convert.ToString(OrdnerExisitiert));
//String lokal = "\\Lokal\\";
try
{
DirectoryInfo infoFiles = new DirectoryInfo((string)listBox1.SelectedItem);
bool of = infoFiles.Exists;
bool af = Directory.Exists((string)listBox1.SelectedItem);
MessageBox.Show(Convert.ToString(of), "Pfad vorhanden", MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBox.Show(Convert.ToString(af));
}
catch (Exception t)
{
MessageBox.Show(Convert.ToString(t));
}
//Directory.CreateDirectory(string dirName);
// String pfade = Path.Combine(selektiertepfad,lokal);
//string selektiertepfad = "D:" + Path.DirectorySeparatorChar + Convert.ToString(listBox1.SelectedItem);//System.IO.Path.Combine("D:", Convert.ToString(listBox1.SelectedItem));
/**MessageBox.Show(selektiertepfad);
if (Directory.Exists(@selektiertepfad))
{
MessageBox.Show(" Ordner vorhanden, Server", "Ordner Vorhanden im Server", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
}
else
{
MessageBox.Show(" Ordner nicht vorhanden,Server!", "Ordner Vorhanden nicht vorhanden im Server!", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
}
/** for (int i = tagvon; i <= tagbis; i++)
{
//MessageBox.Show(Convert.ToString(i));
string filedate = jahrbis + "-" + monatbis + "-" + i;
// MessageBox.Show(filedate,"Datum",MessageBoxButtons.OK,MessageBoxIcon.Information);
//MessageBox.Show(liste);
/** if (Directory.Exists(@serverpfad))
{
MessageBox.Show(filedate + " Ordner vorhanden, Server", "Ordner Vorhanden im Server", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
}
else
{
MessageBox.Show(filedate + " Ordner nicht vorhanden,Server!", "Ordner Vorhanden nicht vorhanden im Server!", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
}
if (Directory.Exists(lokalpfad))
{
MessageBox.Show(filedate + " Ordner vorhanden, Lokal", "Ordner Vorhanden im Lokal", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
}
else
{
MessageBox.Show(filedate + " Ordner nicht vorhanden,Lokal!", "Ordner Vorhanden nicht vorhanden im Lokal!", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
}
*/
}
}
}