Home cant access a file using C# asp mvc application
Reply: 0

cant access a file using C# asp mvc application

user1735
1#
user1735 Published in July 20, 2018, 1:20 am

I have an mvc asp application that needs to edit a file by the name of test.php I didnt have any error using this method in my LocalHost , when i transfered it to server i get this error :

System.UnauthorizedAccessException: Access to the path 'C:\Users\Administrator\Desktop\codeEditor\test.php' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost) at System.IO.File.InternalReadAllText(String path, Encoding encoding, Boolean checkHost) at System.IO.File.ReadAllText(String path) at ASP._Page_Areas_user_Views_php_dark_cshtml.Execute() in C:\Inetpub\vhosts\tutpersia.com\httpdocs\Areas\user\Views\php\dark.cshtml

I tried changing permissions of my directory using Plesk or by right click and ... but still the same error

what Im trying to do in my app is :

  string filePath = "C:\\Inetpub\\vhosts\\sth.com\\httpdocs\\test.php";

            string text = System.IO.File.ReadAllText(filePath);
            System.IO.File.WriteAllText(filePath, text+"sth");

thank you all

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.303741 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO