I have this code:
try
{
using (FileStream fs = File.Create(path)) { }
File.Delete(pathToStore);
File.Copy(path, pathToStore);
}
catch(Exception){}
I believe that the read and write attributes are set because I get the access denied error.
Is there a way to only set the read attribute in my code so i don’t get the access denied error? My path is to a server and i have the permission to open the file and execute the file.
BEWARE that IF
pathis not readonly it gets overwritten by your code according to MSDN !Since the block is empty I would just remove that
usingblock…change your code to
One point though: It is usually a BAD idea to just swallow all exceptions !