# Filsökvägar

## Filsökvägar

En filsökväg i windows kan t.ex. se ut så här:

```
c:\temp\exempel.txt
```

Det betyder:

* Filen finns på enhet C.
* I C finns det en mapp som heter temp.
* I mappen temp finns en fil som heter exempel.
* exempel-filens filändelse är txt.

Med andra ord används \ för att separera enheter, mappar och filnamn. I filnamn används punkt för att separera namn från filändelse.

Eftersom \ redan används som "escape"-tecken i C#, för att t.ex. göra radbrytning \n, så måste man ange filsökvägar så här:

```
string path = @"c:\temp\exempel.txt";
```

@-tecknet gör att \\-tecknen inte tolkas, utan [tas bokstavligt](/grundlaggande/datatyper/string.md#verbatim-strings).

### Filer i samma mapp som programmet <a href="#h.p_gkvdjqel-lgi" id="h.p_gkvdjqel-lgi"></a>

När det gäller filer som ligger i samma mapp som programmet så behöver man inte ange mapp eller enhet.

```
string path = @"localfile.txt";
```

För er som läst webbutveckling bör detta vara bekant.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://csharp.progdocs.se/filhantering/filsoekvaegar.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
