0

I have a image uploader that stores my images on that project location:

C:\Users\example\source\Workspaces\project\projectsample\Content\Files

When I try to access this images with the following URL and code it breaks:

var fileURL = "~/Content/Files/image.png";
byte[] file = File.ReadAllBytes(fileURL);

Cannot find a part of the path

What I'm missing?

EDIT

Solved with the following: How to read existing text files without defining path using AXMIM solution.

Lechucico
  • 1,914
  • 7
  • 27
  • 60

1 Answers1

0

You are on windows and not unix, so your fileURL is wrong. See naming files, paths, and namespaces for more info.

It should look like this:

var fileURL = @".\Content\Files\image.png";

EDIT: before its unclear, the ~ is the wrong character here, / or \ does not matter in that regard.

FeRaaC
  • 486
  • 2
  • 10