-2

I have a directory in my project called IMGwhere I store images.

This is the image of the folder

The idea is to use those images to process them (add a filter to the images) and then do some other stuff, but it seems you can't access local directories from ASP.net (that's what I've read).

What could be a solution to this problem? I am completely new to c# and ASP.net please explain as easy as possible.

This is what I've tried.

string systempath = Directory.GetCurrentDirectory() + "/IMG/";
var filePaths = Directory.GetFiles(systempath, "*", SearchOption.AllDirectories);
Andrey Torres
  • 29
  • 1
  • 7
  • You CAN access folder through asp.net. Show us the relevant code. – SᴇM Oct 26 '17 at 06:24
  • Do i just have to add the directory manually, example: "C:\Program Files (x86)" ?? – Andrey Torres Oct 26 '17 at 06:25
  • What you have tried? – SᴇM Oct 26 '17 at 06:26
  • Directory.GetCurrentDirectory() + "/IMG/"; which i thought would return the directory of the project but it returns the ISS folder directory. – Andrey Torres Oct 26 '17 at 06:27
  • Possible duplicate of [Read files from a Folder present in project](https://stackoverflow.com/questions/13762338/read-files-from-a-folder-present-in-project) – Saadi Oct 26 '17 at 06:29
  • Did you set a property "Copy to Output Directory" on the folder? – user1242967 Oct 26 '17 at 06:30
  • No, i didn't set that property, how do you do that from Visual Studio or File Explorer? – Andrey Torres Oct 26 '17 at 06:33
  • In Visual Studio solution explorer right-click on the folder, click properties and in the Properties windows set Copy to Output Directory to Copy if newer. This will have to be set for every item in the folder but you should be able to do that in one go by select them all before right-clicking. – user1242967 Oct 26 '17 at 06:38

1 Answers1

0

I fixed it with this lines of code:

Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
String Root = Directory.GetCurrentDirectory();

It seemed to worked perfectly, I'm getting the images i wanted, thanks everyone for the help!!

Andrey Torres
  • 29
  • 1
  • 7