Skip to content

Instantly share code, notes, and snippets.

@skenderbeu
Created July 19, 2018 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skenderbeu/4b89fc8699130ab55ca51f69bae8b90e to your computer and use it in GitHub Desktop.
Save skenderbeu/4b89fc8699130ab55ca51f69bae8b90e to your computer and use it in GitHub Desktop.
using System;
using System.IO;
namespace SpreadsheetImporter
{
class Program
{
static void Main(string[] args)
{
ReadFile(@"C:\temp\jam2.xls");
Console.ReadLine();
}
private static void ReadFile(string filePath)
{
try
{
Console.WriteLine($"Content of file is: {File.ReadAllText(filePath)}");
}
catch(IOException)
{
Console.WriteLine($"File {filePath} is already open, please close");
}
catch (Exception ex)
{
Console.WriteLine($"Something has gone wrong, see execption message: {ex.Message}");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment