当我给文件名时如何获取文件的Ful路径 [英] How To Get The Ful Path Of A File When I Give The File Name
本文介绍了当我给文件名时如何获取文件的Ful路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我在vb.net中给出文件名时如何获取文件的完整路径
解决方案
文件名不能立即匹配到文件 - 它不包含路径信息。
然而,您可以获得应用程序当前路径
string curPath = Directory.GetCurrentDirectory();
或
string assPath = Path.GetDirectoryName(Assembly) .GetExecutingAssembly()。Location);
或
string appPath = System.IO.Path.GetDirectoryName(Application .ExecutablePath);
分别为你提供程序集和应用程序所在的路径。
但是。 ..如果您正在写入文件,则应该将其保留在定义的位置。 我应该在哪里存储数据? [ ^ ]建议一些合适的地方。
How to get the ful path of a file when i give the file name in vb.net
解决方案
The file name is not immediately matchable to a file - it contains no path information.
You can however get the application current path with
string curPath = Directory.GetCurrentDirectory();
Or
string assPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
Or
string appPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
which get you the path the assembly and application reside in respectively.
But...if you are writing to the file, you should look at keeping it in a defined location. Where should I store my data?[^] suggests some suitable places.
这篇关于当我给文件名时如何获取文件的Ful路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文