There are a couple of problems. When you fetch the file you wish I presume you are fetching localhost:8000/filename? if so, then when you receive the request in your code and parse the GET request, you should get a path of /filename. You then remove the / from the front and just use filename. This requires that when you run the code you must be sure that your root directory ends with / so for example:
./WebServer /home/username/files/
Without the trailing / you will not correctly construct the full path.
Secondarily, once you read up the file content, you are sending a response header that looks like this:
"HTTP/1.0 200 OK\r\nContent-Length: %ld\r\n"
Where you of course provide the content length of the file requested. This is not quite correct as the HTTP response header must be terminated with a two carriage return line feed character sequence. So change the above response to look like this:
"HTTP/1.0 200 OK\r\nContent-Length: %ld\r\n\r\n"
With those constraints and changes it will work for you.