社区
C#
帖子详情
文件路径读取问题
greyrainbow2010
2012-04-21 03:47:34
Application.StartupPath调试发现是app.exe文件所在的路径
文件目录等级
app--bin--debug--app.exe
app--皮肤--1--1.doc
bin文件夹和皮肤文件夹同在app目录下
这时候我怎么才能取到 “1.doc”的路径呢??
就是相对路径和绝对路径的获取问题
...全文
135
10
打赏
收藏
文件路径读取问题
Application.StartupPath调试发现是app.exe文件所在的路径 文件目录等级 app--bin--debug--app.exe app--皮肤--1--1.doc bin文件夹和皮肤文件夹同在app目录下 这时候我怎么才能取到 “1.doc”的路径呢?? 就是相对路径和绝对路径的获取问题
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
10 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
hoken2020856
2012-04-23
打赏
举报
回复
string path= Application.StartupPath.SubString(0,Application.StartupPath.Length-9);
string docpath=Path.Combin(path,"1\\1.doc");
文件是死的人是活的,你把它挪个方便读取的地方不就得了
liushideyizhenfeng
2012-04-23
打赏
举报
回复
可以看看这个网页
http://www.cnblogs.com/qianqianfy/archive/2009/07/08/1518974.html
小志
2012-04-23
打赏
举报
回复
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace DLAFMS.SysCommon {
/// <summary>
/// 公共类
/// </summary>
public class Global {
/// <summary>
/// 应用程序执行路径
/// </summary>
public static readonly string appDir = GetAppDir();
/// <summary>
/// 获取应用程序执行路径
/// </summary>
/// <returns>应用程序执行路径</returns>
private static string GetAppDir() {
string appName = Application.ExecutablePath;
string[] dirNames = appName.Split(new char[] { '\\' });
return appName.Replace(dirNames[dirNames.Length - 1], @"");
}
}
}
把皮肤放到debug目录下面,访问如下:
Global.appDir + @"皮肤\1.doc";
greyrainbow2010
2012-04-23
打赏
举报
回复
都不对啊,哎。
rayyu1989
2012-04-21
打赏
举报
回复
../../../皮肤/1/1.doc
greyrainbow2010
2012-04-21
打赏
举报
回复
[Quote=引用 2 楼 的回复:]
单步调试 string 路径 =Application.StartupPath;
看看变量得到的知道 再根据实际情况进行追加字符串
[/Quote]
汗,我会追加字符串,但是我上面的需求是先要减几个字符串
不会减啊。
greyrainbow2010
2012-04-21
打赏
举报
回复
[Quote=引用 1 楼 的回复:]
把皮肤放到debug目录下面
Application.StartupPath+"\\"+"皮肤"+"1.doc"
[/Quote]
这个我知道,但是不是我想要的
greyrainbow2010
2012-04-21
打赏
举报
回复
[Quote=引用 1 楼 的回复:]
把皮肤放到debug目录下面
Application.StartupPath+"\\"+"皮肤"+"1.doc"
[/Quote]
这个我知道,但是不是我想要的
orochiheart
2012-04-21
打赏
举报
回复
单步调试 string 路径 =Application.StartupPath;
看看变量得到的知道 再根据实际情况进行追加字符串
事理
2012-04-21
打赏
举报
回复
把皮肤放到debug目录下面
Application.StartupPath+"\\"+"皮肤"+"1.doc"
c语言中,
文件
路径
读取
问题
最近,遇到一个c语言中,
文件
路径
读取
问题
。
问题
是:再一个txt配置
文件
中,存放着要
读取
的某个其他
文件
的
路径
,如何正确的得到这个
文件
路径
。 我首先在用fgets
读取
了txt中的,
文件
路径
存放于path中 char path[200]...
Java
文件
路径
读取
问题
这样就导致
问题
:windows和Linux里的配置
文件
路径
可能不一样,导致生产环境里
读取
不到配置。 解决方案 一.先判断操作系统 String os = System.getProperty("os.name"); 根据os字符串,判断是否包含”...
java
文件
路径
读取
,java中依据
路径
读取
文件
java中根据
路径
读取
文件
根据
文件
路径
读取
文件
.具体代码如下:/*** 根据
文件
路径
读取
文件
* @param path* @return String* @throws IOException*/public static String loadString(String path) throws IOException{...
Qt之
文件
路径
读取
问题
利用QFile file("books.xml")
读取
不到
文件
解决方式: 1.写入绝对
路径
QFile file("D:/lei_project/qtproject/XMLdemo/books.xml");利用qDebug()();打印出当前
路径
路径
为:”D:/lei_project/qtproject/build...
java
读取
file
文件
路径
_Java 中几种获取
文件
路径
的方式
原标题:Java 中几种获取
文件
路径
的方式1. 前言Java开发中我们经常要获取
文件
的
路径
,比如
读取
配置
文件
等等。今天我们就关于
文件
的
路径
和如何
读取
文件
简单地探讨一下。2.
文件
的
路径
文件
的
路径
通常有 相对
路径
与 ...
C#
111,126
社区成员
642,541
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章