I write as in MSDN, I can say I copy from an example. But in such a way that just File.Create is still an error "Access is denied on the path 'c: \ output.PF'". I can not understand what the problem is.

 string sss = v.ToJson(); using (FileStream fs = File.Create(@"c:\output.PF")) { Byte[] info = new UTF8Encoding(true).GetBytes(sss); // Add some information to the file. fs.Write(info, 0, info.Length); } 

Closed due to the fact that off-topic participants aleksandr barakin , insolor , LEQADA , Grundy , Saidolim Jan 24 '16 at 6:39 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - aleksandr barakin, insolor, LEQADA, Grundy, Saidolim
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 3
    probably you do not have permission to create a file on the disk. Try running the program as an administrator to verify this. - Alexcei Shmakov
  • In general, accessing files is best wrapped in try-catch - rdorn
  • @rdorn in try-catch will wrap up later. I need what would work, and not just what would have been and was ignored. - BwehaaFox pm
  • one
    @BwehaaFox Try-Catch, is needed not to ignore, but to inform you what exactly happened. Ignoring exceptions is not the best idea. - rdorn
  • one
    If the studio is running with the UAC mode on as the current user, then recording to the root folder of the system disk is not available. - user199962

1 answer 1

I started Studio on behalf of the administrator and there is no more error.

  • As it was supposed, the matter of access rights - Alexcei Shmakov
  • 2
    That is, you were denied access because there was simply no right to access. Is logical. ;-) - VladD
  • @VladD there is more cant in that after resetting the system I didn’t register the Studio to start again from the admin :) - BwehaaFox
  • @BwehaaFox: It seems that the studio should not be run from the admin, because the programs can do things with “impunity” that will not be allowed on the client’s machine. (For example, write data outside %APPDATA% .) - VladD