Add a CreateOutFile method overload
Changed the file path for the archive folder
This commit is contained in:
parent
9db6ab7db7
commit
421637bda7
@ -15,8 +15,18 @@ namespace TeamHobby.HobbyProjectGenerator.Archive
|
||||
|
||||
// Create the folder where the compress file will be stored
|
||||
public bool CreateArchiveFolder(){
|
||||
string curPath = Directory.GetCurrentDirectory();
|
||||
//string temp = @
|
||||
//string curPath = Directory.GetCurrentDirectory();
|
||||
string curPath = @"C:\";
|
||||
|
||||
// Find the root drive of the program
|
||||
string drive = Path.GetPathRoot(path: curPath);
|
||||
// Check if Drive exists or not
|
||||
if (!Directory.Exists(drive))
|
||||
{
|
||||
Console.WriteLine("Drive {0} not found", drive);
|
||||
return false;
|
||||
}
|
||||
|
||||
string archiveFolder = curPath + "\\HobbyArchive";
|
||||
//Console.WriteLine("Creating a new folder at: {0}", archiveFolder);
|
||||
if (!Directory.Exists(archiveFolder))
|
||||
@ -27,6 +37,7 @@ namespace TeamHobby.HobbyProjectGenerator.Archive
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Return the name of the new output file with Path
|
||||
public string CreateOutFileName() {
|
||||
try {
|
||||
@ -38,7 +49,29 @@ namespace TeamHobby.HobbyProjectGenerator.Archive
|
||||
|
||||
Console.WriteLine("Date: {0}", date);
|
||||
Console.WriteLine("Filepath: {0}", filePath);
|
||||
return path;
|
||||
return filePath;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("ArchiveCon: Creating a file name failed. ");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// Method overload to take in a specific path
|
||||
public string CreateOutFileName(string archivePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
//string path = archivePath + "\\HobbyArchive";
|
||||
Console.WriteLine("The current directory is {0}", archivePath);
|
||||
string date = DateTime.Now.ToString("M_d_yyyy");
|
||||
string fileName = date + "_archive.csv";
|
||||
string filePath = System.IO.Path.Combine(archivePath, fileName);
|
||||
|
||||
Console.WriteLine("Date: {0}", date);
|
||||
Console.WriteLine("Filepath: {0}", filePath);
|
||||
return filePath;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@ -77,13 +77,15 @@ namespace TeamHobby.HobbyProjectGenerator.Main
|
||||
Console.WriteLine("");
|
||||
|
||||
// Creating a file name:
|
||||
string filePath = @"C:\HobbyArchive";
|
||||
Console.WriteLine("Creating file name ... ");
|
||||
string curPath = archive.CreateOutFileName();
|
||||
//string curPath = archive.CreateOutFileName();
|
||||
string curPath = archive.CreateOutFileName(filePath);
|
||||
|
||||
string pathForward = @"C:\Users\Chunchunmaru\Documents\csulbFall2021\HobbyProject\Source Code\main\bin\Debug\net6.0\HobbyArchive";
|
||||
string pathTemp = "C:/Temp/oldlogs10.txt";
|
||||
string pathTempBack = @"C:\Temp\oldlogs10.txt";
|
||||
Console.WriteLine("----------------");
|
||||
//string pathForward = @"C:\Users\Chunchunmaru\Documents\csulbFall2021\HobbyProject\Source Code\main\bin\Debug\net6.0\HobbyArchive";
|
||||
//string pathTemp = "C:/Temp/oldlogs10.txt";
|
||||
//string pathTempBack = @"C:\Temp\oldlogs10.txt";
|
||||
//Console.WriteLine("----------------");
|
||||
|
||||
//Output SQL to a text file
|
||||
sqlDS.CopyToFile(curPath);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user