I got a program ready on the internet to create a folder, so I tried to adapt it for me but I can not do it.
I would like every time I run it, create a subfolder inside the main with a different name, and let that name be the day I was using, so if I used the 2x program the same day it did not delete the first folder just be as if it were double ex 19/09 ... 19/09 (2).
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class CreateFileOrFolder
{
static void Main()
{
// Specify a "currently active folder"
string activeDir = @"B:\Quality\QAS\FOTOS DO FERRAMENTAL";
//Create a new subfolder under the current active folder
string newPath = System.IO.Path.Combine(activeDir, "19/09/2017");
// Create the subfolder
System.IO.Directory.CreateDirectory(newPath);
// Create a new file name. This example generates
// a random string.
string newFileName = System.IO.Path.GetRandomFileName();
// Combina o arquivo com o caminho
newPath = System.IO.Path.Combine(newPath, newFileName);
// Criar arquivo e sobrescrever ele.
// DANGER: System.IO.File.Create will overwrite the file
// Se já existe ele pode ocorrer a criação de arquivos random
if (!System.IO.File.Exists(newPath))
{
using (System.IO.FileStream fs = System.IO.File.Create(newPath))
{
for (byte i = 0; i < 100; i++)
{
fs.WriteByte(i);
}
}
}
// Ler a data de volta para provar
// se o código anterior funciona.
try
{
byte[] readBuffer = System.IO.File.ReadAllBytes(newPath);
foreach (byte b in readBuffer)
{
Console.WriteLine(b);
}
}
catch (System.IO.IOException e)
{
Console.WriteLine(e.Message);
}
// manter o código aberto no debug.
System.Console.WriteLine("Diretorio criado com sucesso, Pressione qualquer tecla para iniciar o programa de captura.");
System.Console.ReadKey();
}
}