I have the code to save a file in a folder in directory
string timestamp = DateTime.Now.ToString(\"MM-dd-yyyy.HH-mm-ss\");
var file = File.Cr
As per the Exceptions section of documentation,the above exception is thrown when
ArgumentException ------- folder is not a member of System.Environment.SpecialFolder.
It means the OS
where you are running this command does not have Environment.SpecialFolder.CommonApplicationData
as one of the special folder.
For knowledge,
Environment.SpecialFolder.ApplicationData
is the most common one. This folder holds per-user, non-temporary application-specific data, other than user documents. A common example would be a settings or configuration file.
Environment.SpecialFolder.CommonApplicationData
is similar, but shared across users. You could use this to store document templates, for instance.
Environment.SpecialFolder.LocalApplicationData
is a non-roaming alternative for ApplicationData
. As such, you'd never store important data there. However, because it's non-roaming it is a good location for temporary files, caches, etcetera. It's typically on a local disk.
I think the problem may be that Environment.SpecialFolder.CommonApplicationData
is common and shared between different users and the user
with which you have logged in is not having rights to access the folder
or the Visual Studio
has not been started in Admin
mode.
EDIT Look at link and try to add a manual registry Common AppData
defined in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\