Click here to Skip to main content
15,896,348 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to get an absolute path to a file located on a directory at server that i create at runtime but when i try to access that file using its absolute path from FileStream then it gives me an error saying "Could not find a part of the path."
Suggest any solution.
Posted
Updated 6-Jun-12 23:34pm
v2

Try this:

C#
using (FileStream fs = new FileStream(Server.MapPath("Files/MyFile.txt"))
{
    .....
}


Hope that helps.
 
Share this answer
 
But the directory is also created at run-time means that directory is not included in our project.

Directory "Videos" exists in the application but the rest of the sub-directories are build at run-time and a file is located in the last directory. I just want to get its absolute path to File-Stream.
????

string file_Path = Server.MapPath("/Videos/" + logged_User.User_Id + "/" + Convert.ToInt32(Session["ID"]) + "/" + file_Name);

var fileStream = new FileStream(filePath, FileMode.Open_Or_Create);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900