Arduino mini with SD + Ethernet not working (SD only works, Ethernet only works)

Hello, I’m trying to use this LC Studio Card reader

http://cdn.instructables.com/FZT/ULKU/H9G19FWD/FZTULKUH9G19FWD.MEDIUM.jpg

with a ENC28J60 Ethernet Network Module

http://hofmannsven.com/website/uploads/2013/06/header_arduino-ethernet-module.png

Having both connected to my Arduino Mini I can run any code that uses the Ethernet interface OR the SD Card interface, whenever I try to run both the ethernet won’t start, displaying garbage data in the serial output (for instance, it should display the ip when it starts, it shows 0.0.045 and stuff like that)…

Here’s the pinout for both the SD and the Ethernet:
SD — Arduino
GND — GND
5v — 5v (I’m using an uno board to program the mini, so I’m using its 5v and 3v3 pins to regulate the voltage)
CS — 10
MOSI — 11
SCK — 13
MISO — 12

Ethernet — Arduino
CS — 5
SI — 11
SO — 12
SCK — 13
VCC — 3v3
GND — GND

The weird thing is that if I run a code with bfill.emit_p sending only constants, the ethernet works:

bfill.emit_p("<h1>Hello World!</h1>");

However, if I just change the line above to something like:

bfill.emit_p(sendHttpResponse("index.html"));

It won’t even start!
Here’s the code for the sendHttpResponse:

const char* sendHttpResponse(const char* path) {
	int c;
	String res = "";
	ifstream file(path);
	if (!file.is_open()) sd.errorHalt("open failed");
	while ((c = file.get()) >= 0) 
		res += (char)c;
	char __dataFileName[sizeof(res)];
	res.toCharArray(__dataFileName, sizeof(res));
	return __dataFileName;
}

Now, if I remove the part that tries to access the SD card everything starts working… I’m starting to think that I might need to add a resistor somewhere, however, I have no idea, not even if that might solve my problem, any ideas?

Thanks a lot!

Ok... so after a few days trying to figure out what was wrong, first thing I had to fix was the bufferSize of the EtherCard library:

byte Ethernet::buffer[300];

Second thing I had to do was moving the CS pin of the ethernet module to the digital pin 10 and the CS pin of the SD card module to the digital pin 4
Now even though it's still not working 100%, I can read a file from the SD and send as an http response

I think you are running out of memory, since the SD library and Ethernet library together fills up all memory on the Arduino. I had the same problem which I never solved due to that I used to many libraries.