Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Chris Mahoney 220 posts 429 karma points
    Jun 20, 2022 @ 06:43
    Chris Mahoney

    Should I have to prefix "wwwroot" on uploaded files?

    Hi everyone,

    I've installed Umbraco 10 on MacOS 12.4 using the instructions at the top of

    I have a document type with an Upload File property, where a JSON file can be uploaded. I then parse this with code. To do this, I expected to be able to use code such as:

    var json = File.ReadAllLines(myContent.MyUploadedFile);

    However, when trying to execute this, it tells me that it can't find the file. Uploaded files go into a subdirectory of wwwroot, and it doesn't seem to look in there by default. After some trial and error I came up with this working code:

    var json = File.ReadAllLines($"wwwroot{myContent.MyUploadedFile}");

    I don't like having to do this though; it seems 'unclean' for want of a better word. Should this be necessary at all or is something wrong with my setup? If it is required, is there a better way of doing it?

    Thanks :)

Please Sign in or register to post replies

Write your reply to: