Reputation: 217
i define a master page with some menu items. Im using the file upload control, I just have an issue with displaying the contents of a file to open it on another content Page: newModel.aspx page. its working will but i cant display the content, im getting an Error: Could not find file 'C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0\C%3a%5cUsers%5chhassan%5cDocuments%5cVisual+Studio+2010%5cWebSites%5cKBD-2013%5cModel%5cTest.edd'.
C# MasterPage-code:
protected void Open_btn_click(object sender, EventArgs e)
{
bool fileOK = false;
string SampleDocuments = Server.MapPath(string.Empty);
if (FileUploadCtrl.HasFile)
{
string fileExtension = System.IO.Path.GetExtension(FileUploadCtrl.FileName).ToLower();
string allowedExtension = ".edd";
if (fileExtension == allowedExtension)
{
fileOK = true;
}
}
if (fileOK == true)
{
string fileName = SampleDocuments + "\\Model" + "\\" + FileUploadCtrl.FileName;
Response.Redirect("~/Model/newModel.aspx?fileName=" + fileName);
}
newModel Page Code:
protected void Page_Load(object sender, EventArgs e)
{
String fileName = HttpUtility.UrlEncode(Request.QueryString["fileName"]);
this.DiagramWebControl1.LoadBinaryDocument(fileName);
}
Upvotes: 0
Views: 10779
Reputation: 2127
If your application runs in a hosted mode (IIS, IIS Development server), you have to work with Server.MapPath("~")
to get the actual directory. By default, the current working directory points to the working directory of your web server.
For more details: http://msdn.microsoft.com/de-de/library/system.web.httpserverutility.mappath.aspx
Upvotes: 1