相对路径(relativePath)是..\..\runtime\a.txt(此信息存储在xml文件中)
openFilePath d:\1\2\rumtime\save.xml
当我打开xml文件时,我要重新得到他的绝对路径
想得到:D:\1\2\runtime\a.txt
请问如何做到,多谢了
private string GetAbsolutePath(string relativePath,string openFilePath)
{
string ResultPath = "";
if(relativePath.StartsWith(@".\"))
{
}
else
{ ResultPath = relativePath;
return ResultPath;
}
return ResultPath;
}
openFilePath d:\1\2\rumtime\save.xml
当我打开xml文件时,我要重新得到他的绝对路径
想得到:D:\1\2\runtime\a.txt
请问如何做到,多谢了
private string GetAbsolutePath(string relativePath,string openFilePath)
{
string ResultPath = "";
if(relativePath.StartsWith(@".\"))
{
}
else
{ ResultPath = relativePath;
return ResultPath;
}
return ResultPath;
}
解决方案 »
- C#如何从本地添加照片
- 如何计算程序运行了多长时间
- WinForm中重绘滚动条以及用重绘的滚动条控制ListBox的滚动
- 关于加密
- 如何把文本数据(txt 或 xls)导入SQL Server 2000数据库(用C#)
- WPF 通过文件路径 获得文件图标 然后在一个image里显示 图片失真问题
- DataGridView怎么锁定焦点在一个单元格
- vs.net做的asp.net项目安装程序,为什么不能把虚拟目录删除干净
- C#如何利用BHO向网页中追加js脚本
- 怎么把ConnectStream都读入byte[]
- 各位辛苦了,50求购C#中,英文加密,解密程序,在线等待
- 好像很笨啊: 大家能对我这个解决方案提点意见吗?都是拍脑壳瞎想的,请多多指教.
比如相对路径是path.txt的文件就是string startpath = Application.startUp;
string realpath = startpah + "path.txt";realpaht就是绝对路径
根据这个类推可以得到相对的路径的绝对路径.这个办法不知道能不能解决你的问题?
Application 类 | Application 成员 | System.Windows.Forms 命名空间 | Application 成员(Visual J# 语法) | C++ 托管扩展编程 要求
平台: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 系列
.NET Framework 安全性:
FileIOPermission 用于获取路径。关联的枚举:FileIOPermissionAccess.PathDiscovery
语言
C#C++JScriptVisual Basic全部显示
获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称。
[Visual Basic]
Public Shared ReadOnly Property StartupPath As String
[C#]
public static string StartupPath {get;}
[C++]
public: __property static String* get_StartupPath();
[JScript]
public static function get StartupPath() : String;
属性值
启动了应用程序的可执行文件的路径。
示例
[Visual Basic, C#, C++] 下面的示例获取该属性并在文本框中显示其值。本示例假定 textBox1 已放置在窗体上。
[Visual Basic]
Private Sub PrintStartupPath()
textBox1.Text = "The path for the executable file that " & _
"started the application is: " & _
Application.StartupPath
End Sub