Is it possible to create a file outside the project folder?

A yes/no question basically.

This is the code I currently use to create and store files.

When the StoragePath is "uploads", it creates an
upload
directory within my project folder.

c#
var savePath = Path.Combine(StoragePath, "test.png");
string directory = Path.GetDirectoryName(savePath);
if (!Directory.Exists(directory))
{
    Directory.CreateDirectory(directory);
}

using (var fileStream = new FileStream(savePath, FileMode.Create))
{
    await myObject.Image.CopyToAsync(fileStream);
}
Was this page helpful?