为了确保您具有应用程序的路径(而不仅仅是当前目录),请使用以下命令:
http://msdn.microsoft.com/zh-
CN/library/system.diagnostics.process.getcurrentprocess.aspx
现在,您有了一个
Process代表正在运行的进程的对象。
然后使用
Process.MainModule.FileName:
http://msdn.microsoft.com/zh-
cn/library/system.diagnostics.processmodule.filename.aspx
最后,使用
Path.GetDirectoryName来获取包含.exe的文件夹:
http://msdn.microsoft.com/zh-
CN/library/system.io.path.getdirectoryname.aspx
所以这就是你想要的:
string folder = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + @"Archive";string filter = "*.zip";string[] files = Directory.GetFiles(folder, filter);
(请注意,
"Archive"现在您的问题是
@"Archive":您需要使用@,以便不会将反斜杠解释为转义序列的开始)
希望有帮助!



