![Filename Filename]()
.. 解决方案 如下所示,您可以在fileupload contorl中获取文件的完整路径: string filePath,fileName; if (FileUpload1.PostedFile!= null ) { filePath = FileUpload1.PostedFile.FileName; // 带路径的文件名。 fileName = FileUpload1.FileName; // 仅文件名。 } 或参考以下链接: http://stackoverflow.com/questions/4242819/getting-the-path-of-a-file-using-fileupload-control [ ^ ] 如果有帮助,请接受回答并投票。 这样做: String Path = HttpContext.Current.Request.PhysicalApplicationPath + FileUpload1.FileName; 或者试试这个String Path = Server.MapPath(FileUpload1.FileName); 希望这会有所帮助你:))。 你可以这样试: - string fileBasePath = Server.MapPath( 〜/) ; string fileName = Path.GetFileName( this .MyFileUploader.FileName); string fullFilePath = fileBasePath + fileName; 仍然如果你没有获得路径然后它的浏览器安全问题。 请参考: - http://forums.asp.net/t/1077850.aspx [ ^ ] guys i have taken Fileupload control, Button and Textboxso when i click on button i want full path of file from fileupload control in the Textbox.. 解决方案 Like below you can get full path of your file in fileupload contorl :string filePath,fileName; if (FileUpload1.PostedFile != null) { filePath = FileUpload1.PostedFile.FileName; // file name with path. fileName = FileUpload1.FileName;// Only file name. }Or refer below link :http://stackoverflow.com/questions/4242819/getting-the-path-of-a-file-using-fileupload-control[^]Accept as answer and vote if help to you.Do in this way : String Path = HttpContext.Current.Request.PhysicalApplicationPath + FileUpload1.FileName;Or try this String Path = Server.MapPath(FileUpload1.FileName);Hope this will help you :).You can try like this:-string fileBasePath = Server.MapPath("~/");string fileName = Path.GetFileName(this.MyFileUploader.FileName);string fullFilePath = fileBasePath + fileName;Still if you not get path then its issue of browser security.refer this:-http://forums.asp.net/t/1077850.aspx[^] 这篇关于我希望从本地主机上的fileupload控件获取完整的文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-27 15:45