如何解决这个错误......?如何将excel表存放在godaddy的文件夹中...请帮助... [英] How to fix this error...? How to store the excel sheet in folder on godaddy..please help...

查看:35
本文介绍了如何解决这个错误......?如何将excel表存放在godaddy的文件夹中...请帮助...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我简要介绍一下这个问题我试图从用户导入excel表并将其存储在我的域的godaddy文件夹中,我在其中创建了一个文件夹并在代码中给出相同的路径,但是当我尝试这样做时向我显示此错误...

描述:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

异常详细信息:System.Web.HttpException:SaveAs方法配置为需要有根路径,路径为'http://brainlines.in/starsforum.org/Forum/Excel Sheets_Individuals / Indvisual .xlsx'没有root。



来源错误:





第25行:

第26行:字符串DuplicateEtry =这些记录已经存在..!;

第27行:FileUpload1.SaveAs(excelPath);

第28行:

第29行:字符串conString = string.Empty;



这是我的代码



let me brief the problem i am trying to import the excel sheet from user and storing that in the godaddy folder of my domain where i have created a folder and given path of same in code behind but when i try to do this its showing me this error...
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The SaveAs method is configured to require a rooted path, and the path 'http://brainlines.in/starsforum.org/Forum/Excel Sheets_Individuals/Indvisual.xlsx' is not rooted.

Source Error:


Line 25:
Line 26: string DuplicateEtry = "These Records are Already Present..!";
Line 27: FileUpload1.SaveAs(excelPath);
Line 28:
Line 29: string conString = string.Empty;

this is my code

//Upload and save the file
            string excelPath = Server.MapPath("http://doamin_name/Forum/Excel Sheets_Individuals/") + Path.GetFileName(FileUpload1.PostedFile.FileName);
            string DuplicateEtry = "These Records are Already Present..!";
            FileUpload1.SaveAs(excelPath);

            string conString = string.Empty;
            string extension = Path.GetExtension(FileUpload1.PostedFile.FileName);





此代码在本地主机上工作正常,它将excelsheet数据保存到数据库并将该excell文件保存到我的笔记本电脑上的文件夹但是当我尝试这样做时它向我显示了这个错误..哪里出错了请纠正我并指导我修复此问题。



This code was working fine on local host it was saving excelsheet data to the database and save that excell file to the folder on my laptop but when i try to do same it showed me this error..where m going wrong please correct me and guide me for same for fixing this.

推荐答案

MapPath中的字符串需要相对于您的网站soot



The string in MapPath needs to be relative to your site soot

string excelPath = Server.MapPath("~/Forum/Excel Sheets_Individuals/") + Path.GetFileName(FileUpload1.PostedFile.FileName);





将文件存储在



yourdomain.com/Forum/Excel Sheets_Individuals



文件夹



that will store the file in the

yourdomain.com/Forum/Excel Sheets_Individuals

folder






此行不正确:

Hi,

This line doesn't look right:
string excelPath = Server.MapPath("http://brainlines.in/starsforum.org/Forum/Excel Sheets_Individuals/") + Path.GetFileName(FileUpload1.PostedFile.FileName);





如果你看一下<的文档a href =https://msdn.microsoft.com/en-us/library/ms524632%28v=vs.90%29.aspx> Server.MapPath方法 [ ^ ],您将看到它的正确用法示例。



我希望以下内容更接近你想要的:



If you have a look at the documentation for the Server.MapPath Method[^], you will see examples of it's correct usage.

I would expect the following to be closer to what you want:

string excelPath = Server.MapPath(string.Concat("/Forum/Excel Sheets_Individuals/",FileUpload1.PostedFile.FileName));





。希望它有所帮助。



... hope it helps.


它仍然没有工作........... :(如何解决这个请告诉我....
its still not working...........:( how to fix this please tell me....


这篇关于如何解决这个错误......?如何将excel表存放在godaddy的文件夹中...请帮助...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆