you don't seem to understand how everything works at all
in the URL "foo.example.com/bar", the domain portion is "foo.example.com". "com" being the top level domain (TLD), "example" second level, "foo" third level. the TLD is the domain extension for public (i.e. on the internet) domains, which means for web purposes the second level domain is the main
one, so to speak.
DNS records for "example.com" will have one or more IPs as A records, which translates "example.com" to the actual numerical address of the server that your site is stored on. With dedicated IPs the IP alone is sufficient to load your website, with shared the IP points you to the server, and the server looks at the domain name that was requested and serves the right page. So basically "example.com" tells the internet where you are.
The same thing happens with subdomains, sub-subdomains, etc. Usually they point to the same IP as the main "example.com" domain, because they're generally used as sub-parts of your website, but you can specify any arbitrary IP address on them if you want to.
A CNAME record can be set on a domain/subdomain/etc. and the value is another domain name, e.g. "example.org" or "baz.example.org". Basically that just tells anyone requesting the domain "hey I have the same DNS records as that other domain, so use those records". It's useful when you want to alias a domain to another, for example. So a CNAME record on "foo.example.com" with the value of "bar.example.org" will cause the requesting person to make a second DNS request to "bar.example.org" and use those records, which makes "foo.example.com" a copy of "bar.example.org".
the folder path, the part after the "/" doesn't come into any of this. The IP address of a server, and hence domain names tell you, and only tell you which server it is on. When you give something a URL like "foo.example.com/bar/baz/qux.txt" it first takes "foo.example.com", finds the DNS records, and figures out which server it is on. Then it talks to that server and asks the server to send it the file "qux.txt" which is located in the "/bar/baz/" folder.
So what did you do wrong?
First, it was likely a dedicated IP because when you visit that IP it shows you the homepage of the service provider. If it was shared it would show you a generic error page or placeholder or nothing at all. And service providers usually do use a dedicated IP for their own homepage.
Second, I have no idea what you mean by creating a CNAME record on "foo.example.com" pointing to the A record of "foo.example.com". Did you use "foo.example.com" as the value of the CNAME record? you can't use the same domain as the one you're setting the CNAME record on for obvious reasons. Did you use an IP address as the value? You don't do that because IP addresses don't have DNS records associated with them, they are actual addresses that point to actual servers. CNAME records are used to make a domain use the same DNS records as another domain.
Third, even if a CNAME record does what it appears that you thought it does, namely forward requests (which it doesn't, see above), the only thing that you told anyone was where to find the server, but not the path on the server where you can locate the page you actually want.
Fourth, you don't assign an IP to a folder. the folder is a location on the server, the server has an IP.
A records and CNAME records don't do what you want to do. What you actually need to use is a HTTP 301 (permanent) or 302 (moved temporarily) redirect that redirects visitors of "foo.example.com" to "example.org/bar". These redirects aren't DNS records so whether you can specify this behaviour in the domain manager directly is dependant on who your DNS host/domain manager provider is. I can specify 302 redirects on mine, for example, and they'll automatically send the HTTP response to anyone requesting a domain. If you can't do this in whatever manager you have, you should be able to configure the subdomain to point to your hosting service then configure the host to send that redirect response to all requests to the address. You can also always just use a small script as the index page of the subdomain and issue a redirect with it, e.g. http://php.net/manua...ion.header.php.