Question: I have a WCF web service that I am hosting in IIS (actually running within the Visual Studio web host i.e. Cassini).

I have a file that I have to access in the root of the web directory from the service, and am having trouble figuring out the user identity that the service accesses the directory as. I've given permission to ASPNET, NETWORK SERVICE, and IUSR, but none of these seem to work.

Anyone know what the user is that a WCF service runs as when it's hosted within IIS?

MORE INFO:

Indeed, the WCF service is running as me (my windows account), but for whatever reason, it still cannot open a file in its root directory. The file failed with "Access is Denied". I've given "Everyone" Full Control of the folder, and it doesn't seem to matter.

Answer: 
By combinig the various solutions I just read, I came up with a cross-platform way to solve that problem.
[Details here](http://blog.x-aeon.com/2014/03/26/how-to-read-one-non-blocking-key-press-in-ruby/), but here is the relevant piece of code: a `GetKey.getkey` method returning the ASCII code or `nil` if none was pressed.

Should work both on Windows and Unix.

```
module GetKey

  # Check if Win32API is accessible or not
  @use_stty = begin
    require 'Win32API'
    false
  rescue LoadError
    # Use Unix way
    true
  end

  # Return the ASCII code last key pressed, or nil if none
  #
  # Return::
  # * _Integer_: ASCII code of the last key pressed, or nil if none
  def self.getkey
    if @use_stty
      system('stty raw -echo') # => Raw mode, no echo
      char = (STDIN.read_nonblock(1).ord rescue nil)
      system('stty -raw echo') # => Reset terminal mode
      return char
    else
      return Win32API.new('crtdll', '_kbhit', [ ], 'I').Call.zero? ? nil : Win32API.new('crtdll', '_getch', [ ], 'L').Call
    end
  end

end

```

And here is a simple program to test it:

```
loop do
  k = GetKey.getkey
  puts "Key pressed: #{k.inspect}"
  sleep 1
end

```

In the link provided above, I also show how to use the `curses` library, but the result gets a bit whacky on Windows.
You may also want to investigate the 'io/wait' library for Ruby which provides the `ready?` method to all IO objects. I haven't tested your situation specifically, but am using it in a socket based library I'm working on. In your case, provided STDIN is just a standard IO object, you could probably quit the moment `ready?` returns a non-nil result, unless you're interested in finding out what key was actually pressed. This functionality can be had through `require 'io/wait'`, which is part of the Ruby standard library. I am not certain that it works on all environments, but it's worth a try. Rdocs: <http://ruby-doc.org/stdlib/libdoc/io/wait/rdoc/>