没有明白楼主的意思? Directory.GetCurrentDirectory(); 方法,获取应用程序的当前工作目录。你为什么要加载那么长的目录了? 这是具体的代码?MSDN上的。 using System; using System.IO;class Test { public static void Main() { try { // Get the current directory. string path = Directory.GetCurrentDirectory(); string target = @"c:\temp"; Console.WriteLine("The current directory is {0}", path); if (!Directory.Exists(target)) { Directory.CreateDirectory(target); } // Change the current directory. Environment.CurrentDirectory = (target); if (path.Equals(Directory.GetCurrentDirectory())) { Console.WriteLine("You are in the temp directory."); } else { Console.WriteLine("You are not in the temp directory."); } } catch (Exception e) { Console.WriteLine("The process failed: {0}", e.ToString()); } } }
Directory.GetCurrentDirectory();
方法,获取应用程序的当前工作目录。你为什么要加载那么长的目录了?
这是具体的代码?MSDN上的。
using System;
using System.IO;class Test
{
public static void Main()
{
try
{
// Get the current directory.
string path = Directory.GetCurrentDirectory();
string target = @"c:\temp";
Console.WriteLine("The current directory is {0}", path);
if (!Directory.Exists(target))
{
Directory.CreateDirectory(target);
} // Change the current directory.
Environment.CurrentDirectory = (target);
if (path.Equals(Directory.GetCurrentDirectory()))
{
Console.WriteLine("You are in the temp directory.");
}
else
{
Console.WriteLine("You are not in the temp directory.");
}
}
catch (Exception e)
{
Console.WriteLine("The process failed: {0}", e.ToString());
}
}
}
我我嫌显示的太长了,能不能缩掉一些而已,想知道有没有现成的类或方法