Get to know MDN better
このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2023年3月.
安全なコンテキスト用: この機能は一部またはすべての対応しているブラウザーにおいて、安全なコンテキスト (HTTPS) でのみ利用できます。
FileSystemDirectoryHandle インターフェイスの getFileHandle() メソッドは、メソッドが呼ばれたディレクトリー内の指定した名前のファイルを表す FileSystemFileHandle を返します。
取得したいファイルの FileSystemHandle.name を表す文字列です。
options 省略可以下のプロパティを持つオブジェクトです。
createBoolean です。デフォルトは false です。 true に設定すると、ファイルが見つからない場合、指定した名前のファイルが作成されて返されます。
FileSystemFileHandle で解決する Promise を返します。
PermissionStatus が 'granted' でないとき投げられます。
TypeError指定された名前が有効な文字列でないか、ネイティブのファイルシステムで支障が出る文字を含むとき投げられます。
TypeMismatchError DOMException指定されたエントリーがディレクトリーであってファイルではないとき投げられます。
NotFoundError DOMExceptionファイルが存在せず、create オプションが false に設定されているとき投げられます。
以下の例では、指定の名前のファイルハンドルを返します。ファイルが存在しない場合、作成されます。
| File System # api-filesystemdirectoryhandle-getfilehandle |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025年6月24日 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.