vb.net获取app文件夹中的文件夹路径 [英] vb.net getting path of folder in the app folder

查看:618
本文介绍了vb.net获取app文件夹中的文件夹路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的app文件夹中有一个报告文件夹

i需要给出路径

但是我无法获得路径我总是将路径作为物理路径应用程序/调试/报告

但报告文件夹位于应用程序根路径

i have a reports folder in my app folder
i need to give thhe path
but i am not able to get the path i always get the path as physical path of application/debug/report
but report folder is in the application root path

推荐答案

听起来好像是在调试中运行应用程序Visual Studio中的模式。在这种情况下,应用程序的根路径是debug文件夹。这是您运行的exe文件的位置。如果要在应用程序中包含具有报告的目录,则需要将其添加到项目中,或者需要手动创建。当您创建一个安装项目来部署您的应用程序时,您可以选择在应用程序的根目录下添加文件夹。



如果您包含的文件与您的项目,将它们放在应用程序的文件夹中,并将它们标记为应始终复制的内容文件。然后,当您编译应用程序时,它将创建该文件夹并将这些内容文件放在该文件夹中。然后你可以使用相对路径来引用它们。



底线是你的项目的根文件夹不是你的应用程序的根文件夹。相反,您的根文件夹是运行exe的位置(在本例中为调试目录)。如果您希望内容相对于应用程序目录的根目录,则需要手动复制它,将其包含在安装文件中,或将其包含在项目中并将其标记为内容文件。
It sounds like you are running your application in debug mode in Visual Studio. In that case, the root path for your application is the debug folder. That is where your exe file is that you are running. If you want to include a directory in your application that has reports, you need to add that to your project or you need to create it manually. When you create a setup project to deploy your application, you will have the option of adding folders at the root of your application.

If you are including files that go with your project, put them in a folder in your application and mark them as content files that should always be copied. Then, when you compile your application, it will create that folder and put those content files in the folder. Then you can reference them using the relative path.

The bottom line is that your project's root folder is not your application's root folder. Instead, your root folder is wherever your exe is running from (in this case, the debug directory). If you want content to be relative to the root of the application's directory, you either need to copy it manually, include it in an install file, or include it in the project and mark it as a content file.




您可以使用

you can find root path by using
Application.StartupPath



这用于既可以在客户端也可以在你的开发方面,

返回.exe文件的根路径。



我希望这会有所帮助你。

所有最好的

:)


this is used at both place at client side and your developing side also,
its returns root path of your .exe file.

I Hope this will help you.
All The Best
:)


Application.StartupPath.ToLower.Replace(\ bin\debug ,)。替换(\ bin \ release,)
Application.StartupPath.ToLower.Replace("\bin\debug", "").Replace("\bin\release", "")


这篇关于vb.net获取app文件夹中的文件夹路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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