Contact Form

Name

Email *

Message *

Cari Blog Ini

Basedirectory C

Getting Files in the Same Directory as Your Application

Getting the File Path of the Application

To get the file path of your application, you can use the following code in .NET Core 3.1:

```csharp string appDirectory = AppContext.BaseDirectory; ```

This will give you the base directory for class libraries, including those in ASP.NET applications.

Getting Files in the Same Directory as the Application

Once you have the application directory, you can use it to get files in the same directory. For example, to get all the files in the same directory as your application, you can use the following code:

```csharp string[] files = Directory.GetFiles(appDirectory); ```

This will return an array of strings containing the full paths of all the files in the same directory as your application.


Comments