【问题标题】:Could not find file 'C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0'找不到文件“C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0”
【发布时间】:2013-05-16 19:27:53
【问题描述】:

我定义了一个包含一些菜单项的母版页。我使用文件上传控件,我只是在显示文件内容以在另一个内容页面上打开它时遇到问题:newModel.aspx 页面。它的工作将,但我无法显示内容,我得到一个错误: 找不到文件 '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-代码:

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 页面代码:

protected void Page_Load(object sender, EventArgs e)
{
    String fileName = HttpUtility.UrlEncode(Request.QueryString["fileName"]);
    this.DiagramWebControl1.LoadBinaryDocument(fileName);
}

【问题讨论】:

    标签: c# asp.net syncfusion


    【解决方案1】:

    如果您的应用程序在托管模式下运行(IIS、IIS 开发服务器),您必须使用Server.MapPath("~") 来获取实际目录。默认情况下,当前工作目录指向您的 Web 服务器的工作目录。 更多详情:http://msdn.microsoft.com/de-de/library/system.web.httpserverutility.mappath.aspx

    【讨论】:

    • 我的应用程序在本地主机上运行
    • 但是你使用IIS?还是 IIS 开发服务器?
    • 对不起,我忘记用 IIS 写了
    • 好的,不管你是在本地主机上还是在生产机器上。如果你使用 IIS,那么你必须使用Server.MapPath
    猜你喜欢
    • 1970-01-01
    • 2015-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-25
    • 2014-05-10
    • 1970-01-01
    • 2016-08-04
    相关资源
    最近更新 更多