Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.