[Win32utils-devel] File.open on a directory?

win32utils-devel at rubyforge.org win32utils-devel at rubyforge.org
Thu Nov 11 02:49:52 EST 2004


Hi,
> 
> Hi all,
> 
> Windows 2000
> Ruby 1.8.2 RC9
> 
> Is it possible to call File.open on a directory in Windows?  I always get 
> Errno::EACCES, even though there are no special settings on the directories 
> I've tried and I have full access.
> 
> Dan
> 
The open function cannot open directory on Windows. it returns EACCES if given path is directory.

You should use CreateFile function to open directory.
Opening a directory with CreateFile requires the FILE_FLAG_BACKUP_SEMANTICS flag.

Refer to
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt__open.2c_._wopen.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/createfile.asp

Regards,

Park Heesob



--MIME Multi-part separator--



More information about the win32utils-devel mailing list