Delphi CGI(IIS 7.5、Win 7):系统找不到指定的文件

发布于 2024-10-08 19:47:16 字数 669 浏览 0 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

獨角戲 2024-10-15 19:47:16

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.

云雾 2024-10-15 19:47:16

确保代表 IIS 操作的用户对此文件具有 NTFS 权限。

Make sure that user, on behalf of which IIS acts, has NTFS permissions on this file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文