DOS短名称 [英] DOS Short Names

查看:73
本文介绍了DOS短名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个表示路径的strig,我怎样才能以编程方式获得

" short"它的DOS名称?


例如,如果我有C:\Program Files \我想要C:\ Progra~1 \。


谢谢

If I have a strig that represents a path, how can I programmatically get the
"short" DOS name for it?

For example, if I have "C:\Program Files\" I want "C:\Progra~1\".

Thanks

推荐答案

如果我有一个表示路径的strig,我怎么能以编程方式获得
If I have a strig that represents a path, how can I programmatically get

short"它的DOS名称?


例如,如果我有C:\Program Files \我想要C:\ Progra~1 \。
the "short" DOS name for it?

For example, if I have "C:\Program Files\" I want "C:\Progra~1\".



AFAIK,没有原生.NET功能可以做到这一点。你可以简单地依靠

" GetShortPathName()"在WinAPI中,假设您的应用程序针对的是Windows(以及哪个.NET应用程序)。这是第一个用Google搜索的第一个例子

forC#和GetShortPathName() (还有更多)

http:/ /www.pinvoke.net/default.aspx/...tShortPathName


作弊:)


public string FakeDosFileString(string myStr)

string [] myChildren = myStr.split(new char [] {''\\''}};

string Answer = " ;;


for(int x = 0; x< myChildren.length; x ++)

{

if(myChildren [x] .length 8)

myChildren [x] = myChildren [x] .substring(0,6)+ @" ~1" ;;

答案+ = myChildren [x] +" \\" ;;

}

返回答案;

}


我还没有通过编译器运行....

希望修复你的概率。

CapCity写道:
Cheat :)

public string FakeDosFileString(string myStr)
string[] myChildren = myStr.split(new char[] {''\\''});
string Answer = "";

for(int x = 0; x < myChildren.length; x++ )
{
if (myChildren[x].length 8)
myChildren[x] = myChildren[x].substring(0,6) + @"~1";
Answer += myChildren[x] + "\\";
}
return Answer;
}

I didnt run this through the compliler yet....
Hope the fixes you prob.
"CapCity" wrote:

如果我有一个表示路径的strig,我怎样才能以编程方式获得

" short"它的DOS名称?


例如,如果我有C:\Program Files \我想要C:\ Progra~1 \。


谢谢
If I have a strig that represents a path, how can I programmatically get the
"short" DOS name for it?

For example, if I have "C:\Program Files\" I want "C:\Progra~1\".

Thanks


TheMadHatter,


男人,别误会我的意思。但有时我们有~2,~3,数字等等。我不认为b $ b认为这对所有事情都有效。


我已经在互联网上发现了一篇非常有趣的文章。
http://www.c-sharpcorner.com/UploadF...d-8d2348b8c6d2


-

问候,

Robson Siqueira

企业架构师

" TheMadHatter" < Th ********** @ discussion.microsoft.com写信息

新闻:EC ****************** **************** @ microsof t.com ...
TheMadHatter,

Man, don''t get me wrong. but sometimes we have ~2, ~3, numbers, etc. I don''t
think that would work for everything.

I''ve found a pretty interesting article on the internet.
http://www.c-sharpcorner.com/UploadF...d-8d2348b8c6d2

--
Regards,
Robson Siqueira
Enterprise Architect
"TheMadHatter" <Th**********@discussions.microsoft.comwrote in message
news:EC**********************************@microsof t.com...

作弊:)


public string FakeDosFileString(string myStr)

string [] myChildren = myStr.split(new char [] {''\\''}};

string Answer ="" ;;


for(int x = 0; x< myChildren.length; x ++)

{

if(myChildren [x] .length 8)

myChildren [x] = myChildren [x] .substring(0,6)+ @" ~1";

答案+ = myChildren [x] +" \\" ;;

}

返回答案;

}


我还没有通过编译器运行....

希望修复你的概率。


CapCity写道:
Cheat :)

public string FakeDosFileString(string myStr)
string[] myChildren = myStr.split(new char[] {''\\''});
string Answer = "";

for(int x = 0; x < myChildren.length; x++ )
{
if (myChildren[x].length 8)
myChildren[x] = myChildren[x].substring(0,6) + @"~1";
Answer += myChildren[x] + "\\";
}
return Answer;
}

I didnt run this through the compliler yet....
Hope the fixes you prob.
"CapCity" wrote:

>如果我有一个表示路径的strig,我怎样才能以编程方式获得
short"它的DOS名称?

例如,如果我有C:\Program Files \我想要C:\ Progra~1 \。
谢谢
>If I have a strig that represents a path, how can I programmatically get
the
"short" DOS name for it?

For example, if I have "C:\Program Files\" I want "C:\Progra~1\".

Thanks



这篇关于DOS短名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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