2
I took a program ready on the internet to create folder, so I tried to adapt it for me but I’m not getting.
I’d like every time I executed it, to create a subfolder inside the main under a different name, and that name be the day I was using it, hence if using 2x on the same day it would not erase the first folder just 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();
}
}
And what is your doubt?
– Maniero
as I create several subfolders with different name, one not erasing the other
– Felipe Deolindo