Reputation: 5524
I have an MVC4 application, one controller method takes some files (this files has some Json Objects), read it proccessit then deleteit.
Those files are uploaded to my site using ftp. My Project structures is sometrhing like this
wwwroot
bin
content
images
scripts
suscribers // This is my ftp folder
_suscriber1
_proccess1
file1.txt //This is a Json file
file2.txt
...
_proccess2
...
_suscriber2
...
All my files (file1.txt...) are loaded ok. At my controller, i'm trying to read file1.txt this way:
string suscriberDir= string.Format("_{0}", suscriber.Id);
string[] laPath = {System.AppDomain.CurrentDomain.BaseDirectory, "suscribers", suscriberDir};
string lcPath = Path.Combine(laPath);
string[] laPath2 = { lcPath, "_proccess1" , "_File1.txt" };
lcPath = Path.Combine(laPath2);
StreamReader reader = new StreamReader(lcPath);
string personas = reader.ReadToEnd();
reader.Close();
My problema is that it is throwing me a filenotfound exception.
What is the right way to read file1.txt and get its content?
Upvotes: 2
Views: 9099