# How do I read the currently focused file?
#obsidian/api/faq
---
Reading the current file contents is a two-step process:
1. Retrieve the current view from the [[Workspace]].
2. Read the view's file from the [[Vault]].
## Sample Code
```ts
import type { MarkdownView } from 'obsidian';
/* ... */
const { workspace } = this.app;
const activeView = workspace.getActiveViewOfType(MarkdownView);
if (activeView) { // The active view might not be a markdown view
// Read the file (from either the cache or from disk)
// Note: `cachedRead` returns stale data which should be good for most cases.
// However, if you plan on writing back to disk, use `vault.read` here
// instead to avoid data loss.
const fileContents = vault.cachedRead(activeView.file);
}
```