无法使用 C# asp mvc 应用程序访问文件
cant access a file using C# asp mvc application
我有一个 mvc asp 应用程序需要编辑名为 test.php 的文件
我在 LocalHost 中使用此方法没有任何错误,当我将其传输到服务器时出现此错误:
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
我尝试使用 Plesk 或通过右键单击更改我的目录的权限...但仍然出现相同的错误
我想在我的应用程序中做的是:
string filePath = "C:\Inetpub\vhosts\sth.com\httpdocs\test.php";
string text = System.IO.File.ReadAllText(filePath);
System.IO.File.WriteAllText(filePath, text+"sth");
谢谢大家
您需要设置授权以允许IIS_IUSRS。还请强制将权限应用于所有 subfolders/files.
出于安全考虑,请注意允许 IIS_IUSRS 的内容。
我有一个 mvc asp 应用程序需要编辑名为 test.php 的文件 我在 LocalHost 中使用此方法没有任何错误,当我将其传输到服务器时出现此错误:
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
我尝试使用 Plesk 或通过右键单击更改我的目录的权限...但仍然出现相同的错误
我想在我的应用程序中做的是:
string filePath = "C:\Inetpub\vhosts\sth.com\httpdocs\test.php";
string text = System.IO.File.ReadAllText(filePath);
System.IO.File.WriteAllText(filePath, text+"sth");
谢谢大家
您需要设置授权以允许IIS_IUSRS。还请强制将权限应用于所有 subfolders/files.
出于安全考虑,请注意允许 IIS_IUSRS 的内容。