Tuesday 15 March 2016

Check file exists using c#

if (File.Exists(filePath)) {   
    byte[] data = File.ReadAllBytes(filePath);
    string fileName = Path.GetFileName(filePath);

    const string query = "INSERT INTO Files (FileName, Data, Path) VALUES (@FileName, @Data, @Path)";

    using (var connection = new SqlConnection(connectionString))
    using (var command = new SqlCommand(query, connection)) {
        command.Parameters.AddWithValue("@FileName", fileName);
        command.Parameters.AddWithValue("@Data", data);
        command.Parameters.AddWithValue("@Path", filePath);

        connection.Open();
        command.ExecuteNonQuery();
    }
}

http://www.codeproject.com/Tips/849516/How-to-Search-for-an-Excel-File-in-a-Folder-using
http://www.codeproject.com/Articles/368530/Dynamic-Excel-file-loading-with-SSIS
https://www.youtube.com/watch?v=_B83CPqX-N4
https://www.youtube.com/watch?v=Ui4vera72Ng

No comments:

Post a Comment