Allow file rewriting - C # / ASP.NET

During the implementation of reading / writing XML files in my application, I saw that when I called XElement.Save ("myfile.xml"), it would overwrite the existing file.

Is this the default behavior for all methods that save files in C # / ASP.NET or depends on the permissions granted by ASP.NET?

If my application will be deployed by different people on different hosting settings, what factors should be taken into account for possible restrictions (if any) that can be placed in my application when reading / writing files?

Will a specific server setup allow me to overwrite existing files when deleting an old one?

When saving files to be used later by my application, is App_Data the safest folder to save them?

+3
source share
3 answers

The problem with the default behavior is really a separate beastie from the permission problem ...

, .NET Framework, . , , . , . , XmlDocument.Save , . , FileStream, FileMode, Create ( , XmlDocument.Save(string)).

/ , , ( ), :

  • , , // ( ) .
  • .
+2

, #/ASP.NET: MSDN . , StreamWriter , . , XElement.Save , , , , , , , .

, XElement.Save , , , XElement.Save( , .NET reference source). , Framework.

: , App_Data - , .

+1

you may have work to check if the file exists or not.

0
source

Source: https://habr.com/ru/post/1721530/


All Articles