Delphi CGI(IIS 7.5、Win 7):系统找不到指定的文件
我有一个 CGI 应用程序(Delphi 7)。在某些时候,它会执行以下代码:
FileMode := fmOpenRead or fmShareDenyWrite;
AssignFile( user_file, FULL_PATH_TO_USER_INFO_FILE_NAME);
{$I-} Reset( user_file, sizeof( TUserInfoRec));
//
// some IOResult checking here..
//
Result := FileSize( user_file) - 1;
CloseFile( user_file);
该应用程序在带有 IIS 5.1 的 Windows XP SP3 上运行良好。在带有 IIS 7.5 的 Windows 7 上,无法打开该文件。错误出现在重置行 - “系统找不到指定的文件。”但是,如果我尝试使用 TIniFile 写入它,它就会起作用。
ini_file := TIniFile.Create( FULL_PATH_TO_USER_INFO_FILE_NAME);
ini_file.WriteString( 'Section','Ident','Value') ;
我认为这与 IIS 权限有关,但经过一番搜索后,我没有主意了。
有人可以帮我吗?
谢谢!
I have a CGI application (Delphi 7). At some point it goes through this code:
FileMode := fmOpenRead or fmShareDenyWrite;
AssignFile( user_file, FULL_PATH_TO_USER_INFO_FILE_NAME);
{$I-} Reset( user_file, sizeof( TUserInfoRec));
//
// some IOResult checking here..
//
Result := FileSize( user_file) - 1;
CloseFile( user_file);
The application works fine on Windows XP SP3 with IIS 5.1. On Windows 7 with IIS 7.5 it can't open the file. The error appears at the Reset line - "The system cannot find the file specified." However, if I try to write to it using TIniFile it works.
ini_file := TIniFile.Create( FULL_PATH_TO_USER_INFO_FILE_NAME);
ini_file.WriteString( 'Section','Ident','Value') ;
I assume it has to do with IIS permission, but after searching high and low, I'm out of ideas.
Can anyone help me please?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
USER_INFO_FILE_NAME 是否包含文件的完整路径?
TIniFile 默认情况下在 Windows 文件夹中创建它,因此不需要完整路径。
Does USER_INFO_FILE_NAME contains the full path to file?
TIniFile by default creates it in Windows folder, so it doesn't need full path.
确保代表 IIS 操作的用户对此文件具有 NTFS 权限。
Make sure that user, on behalf of which IIS acts, has NTFS permissions on this file.