Asp.net get file path
Improve this answer. I changed the myPath attribute in web. If so, you don't need the UNC. A local path and of course no Server. If not, caution, Directory. GetFiles may be not enough : you will probably have to handle remote authentication to UNC! Add a comment. MapPath specifies the relative or virtual path to map to a physical directory.
MapPath ".. Community Bot 1 1 1 silver badge. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name.
Email Required, but never shown. The Overflow Blog. Stack Gives Back NET Core versions older than 2. The following example demonstrates the behavior of the GetFileName method on a Windows-based desktop platform.
Skip to main content. This browser is no longer supported. Download Microsoft Edge More info. Contents Exit focus mode. You can then use the base file path to create a full path to the resource you need. The two most commonly used ASP. NET features for determining a file path are properties of the HttpRequest object that return path information, and the MapPath method.
Physical file paths should not be sent to the client because they could be used by a malicious user to gain information about your application. The following table lists properties of the HttpRequest object that help you determine the paths of resources in your application.
Gets the root path of the current application, regardless of where in the application you request it. Gets the virtual path of the current request. Differs from the FilePath property in that CurrentExecutionFilePath is correct if the request has been redirected in server code.
If you get the property in code that is running as a result of a call to Transfer or Execute , the path reflects the location of the code. Gets the physical file system path of the currently executing application's root directory.
Gets the physical file-system path that corresponds to the requested URL. The MapPath method returns the complete physical path for a virtual path that you pass to the method. For example, the following code returns the file path for the root of your Web site:. Please rate your experience Yes No. Any additional feedback?
Namespace: System. IO Assembly: System. In this article.
0コメント