profile.SetPreference
is explicitly used for profile setting modifier.It would have been helpful to find the issue with you code if you provide the Webdriver,FF driver and browser versions.
Though I have used the below furnished code in my code and it has been executed properly.
Selenium version: 3.3.1
OS:Win 7 64b
Browser: Firefox
Browser version:53.0.3
// Create a firefoxprofile for firefox specific settings
FirefoxProfile profile = new FirefoxProfile();
// Set the downloads folder
profile.setPreference("browser.download.dir", path/to/folder);
// Download files to the downloads folder
profile.setPreference("browser.download.folderList", 2);
// Don't show downloads window when download starts
profile.setPreference("browser.download.manager.showWhenStarting", False);
// Prevent file download dialog to be shown for certain MIME-types
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/pdf");