Change handling of files

This commit is contained in:
Matt Nadareski
2016-04-20 02:33:59 -07:00
parent 622832a086
commit f5b40b7c7c

View File

@@ -55,18 +55,7 @@ namespace SabreTools
/// <param name="logger">Logger object for file or console output</param> /// <param name="logger">Logger object for file or console output</param>
public Import(string filepath, string connectionString, Logger logger) public Import(string filepath, string connectionString, Logger logger)
{ {
// Take care of quotes _filepath = filepath.Replace("\"", "");
filepath = filepath.Replace("\"", "");
if (File.Exists(filepath))
{
_filepath = filepath;
}
else
{
throw new IOException("File " + filepath + " does not exist!");
}
_connectionString = connectionString; _connectionString = connectionString;
_logger = logger; _logger = logger;
} }
@@ -77,6 +66,13 @@ namespace SabreTools
/// <returns>True if the data was imported, false otherwise</returns> /// <returns>True if the data was imported, false otherwise</returns>
public bool ImportData () public bool ImportData ()
{ {
// If file doesn't exist, error and return
if (!File.Exists(_filepath))
{
_logger.Error("File '" + _filepath + "' doesn't exist");
return false;
}
// Determine which dattype we have // Determine which dattype we have
string filename = Path.GetFileName(_filepath); string filename = Path.GetFileName(_filepath);
GroupCollection fileinfo; GroupCollection fileinfo;