Process.Start 打开文件的问题? 在线等! Process.Start( "notepad.exe", "\"C:\\Documents and Settings\\A\\My Documents\\a.txt\"" ); 试试看这个不过你的代码在我的机器上是没有错误的,呵呵 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1、用API ShellExecute来调用文件,see:[DllImport("shell32.dll", EntryPoint="ShellExecuteA")]private static extern int ShellExecute(int hwnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, int nShowCmd);bytton1_Click(){string s=@"C:\Documents and Settings\A\My Documents\a.txt";ShellExecute(0,null,s,null,null,5);}2、用API GetShortPathName得到短文件名,然后再调用这个短文件名,see:button1_Click(){ string s=@"C:\Documents and Settings\A\My Documents\a.txt"; string sShort=ToShortPathName(s); Console.WriteLine(sShort); Process.Start("notepad.exe", sShort); }[DllImport("kernel32.dll", EntryPoint="GetShortPathNameA")]private static extern int GetShortPathName(string lpszLongPath, StringBuilder lpszShortPath, int cchBuffer);/// <summary>/// The ToLongPathNameToShortPathName function retrieves the short path form of a specified long input path/// </summary>/// <param name="longName">The long name path</param>/// <returns>A short name path string</returns>public string ToShortPathName(string longName){ StringBuilder shortNameBuffer = new StringBuilder(); int size = GetShortPathName(longName, shortNameBuffer, shortNameBuffer.Capacity); if(size >= shortNameBuffer.Capacity) { shortNameBuffer.Capacity = size + 1; GetShortPathName(longName, shortNameBuffer, shortNameBuffer.Capacity); } return shortNameBuffer.ToString();} 如何遍历Button按钮 把<option value='adm....这条语句改成c#脚本,怎么改?? C# 基于互联网的C/S结构问题 关于combox数据绑定的一个小问题 VS2005的一个设置问题 如何获取一个文件夹的大小 c#,数据库-DataSet-XML-HTML特殊字符转换问题! 想使用C#写一个Windows服务,实现此服务自动检查硬盘某文件夹里的所有文件,并将文件名以字符格式写入SQL C#控制台如何清屏呀?谢了先 急求 c# 时间日期格式转换 做一个本地端的proxy? 谁做财务管理方面的软件能否给点资料关于凭证模块方面的
private static extern int ShellExecute(int hwnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, int nShowCmd);bytton1_Click()
{
string s=@"C:\Documents and Settings\A\My Documents\a.txt";
ShellExecute(0,null,s,null,null,5);
}2、用API GetShortPathName得到短文件名,然后再调用这个短文件名,see:button1_Click()
{
string s=@"C:\Documents and Settings\A\My Documents\a.txt";
string sShort=ToShortPathName(s);
Console.WriteLine(sShort);
Process.Start("notepad.exe", sShort);
}
[DllImport("kernel32.dll", EntryPoint="GetShortPathNameA")]
private static extern int GetShortPathName(string lpszLongPath, StringBuilder lpszShortPath, int cchBuffer);
/// <summary>
/// The ToLongPathNameToShortPathName function retrieves the short path form of a specified long input path
/// </summary>
/// <param name="longName">The long name path</param>
/// <returns>A short name path string</returns>
public string ToShortPathName(string longName)
{
StringBuilder shortNameBuffer = new StringBuilder();
int size = GetShortPathName(longName, shortNameBuffer, shortNameBuffer.Capacity);
if(size >= shortNameBuffer.Capacity)
{
shortNameBuffer.Capacity = size + 1;
GetShortPathName(longName, shortNameBuffer, shortNameBuffer.Capacity);
} return shortNameBuffer.ToString();
}