Expand Minimize

Do not write to the SharePoint file system

Do not create directories or write to files in the SharePoint file system. If this is necessary (e.g. in TimerJobs) ensure that no SharePoint system files are overwritten, that the file size is limited and will not exceed uncontrolled and ensure, that these files are deleted during deinstallation of your code.

CheckId SPC030207
TypeName DoNotWriteToFileSystem
Severity Error
Type Assembly

Remove the instruction which writes to the file system. Note: In some cases it may be appropriate to write to the TEMP directory but the rule cannot evaluate the used path for the file operation. In this case please review the code and suppress this rule if needed.

To suppress this violation in managed code add the following attribute to the method which contains the instruction (available since SPCAF version v5.2). Learn more about SuppressMessage here.

// Important: Ensure to have #define CODE_ANALYSIS at the beginning of your .cs file
[SuppressMessage("SPCAF.Rules.SupportabilityGroup", "SPC030207:DoNotWriteToFileSystem", Justification = "Provide reason for suppression here")]
Disclaimer: The views and opinions expressed in this documentation and in SPCAF do not necessarily reflect the opinions and recommendations of Microsoft or any member of Microsoft. SPCAF and RENCORE are registered trademarks of Rencore. All other trademarks, service marks, collective marks, copyrights, registered names, and marks used or cited by this documentation are the property of their respective owners.