怎么取得一个文件夹的路径 我用vs打开一个项目。现在我想获取该项目下debug文件夹的路径。不使用openFileDialog。有什么语句可以实现吗?绝对,相对都可以。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 是在控制台中,还是在Form中? 1.获取和设置当前目录的完全限定路径。string str = System.Environment.CurrentDirectory;Result: C:\xxx\xxx2.获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称。string str = System.Windows.Forms.Application.StartupPath;Result: C:\xxx\xxx3.获取新的 Process 组件并将其与当前活动的进程关联的主模块的完整路径,包含文件名。string str = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;Result: C:\xxx\xxx\xxx.exe4.获取当前 Thread 的当前应用程序域的基目录,它由程序集冲突解决程序用来探测程序集。string str = System.AppDomain.CurrentDomain.BaseDirectory;Result: C:\xxx\xxx\5.获取应用程序的当前工作目录。string str = System.IO.Directory.GetCurrentDirectory();Result: C:\xxx\xxx6.获取和设置包含该应用程序的目录的名称。string str = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;Result: C:\xxx\xxx\7.获取当前进程的完整路径,包含文件名。string str = this.GetType().Assembly.Location;Result: C:\xxx\xxx\xxx.exe8.获取启动了应用程序的可执行文件的路径,包括可执行文件的名称。string str = System.Windows.Forms.Application.ExecutablePath; Result: C:\xxx\xxx\xxx.exe string s = Application.StartupPath; MessageBox.Show(s); string spath = System.Windows.Forms.Application.StartupPath + "\\******";//****为文件夹名 string mypath = Application.StartupPath; http://blog.csdn.net/donhao/archive/2010/06/01/5638257.aspx跨平台获取当前工作目录 前台获取方法html:<asp:FileUpload runat="server" id="CardUpload"></asp:FileUpload> <input id="Import" onclick="GetUrl();" type="button" value="导入" class="button" runat="server" /> <asp:HiddenField ID="hidPath" runat="server" />js代码: function GetUrl() { //判断浏览器类型 var isIE = (document.all) ? true : false; var isIE7 = isIE && (navigator.userAgent.indexOf('MSIE 7.0') != -1); var isIE8 = isIE && (navigator.userAgent.indexOf('MSIE 8.0') != -1); var file = document.getElementById("CardUpload"); if (isIE7 || isIE8) { file.select(); document.getElementById("hidPath").value = document.selection.createRange().text; document.selection.empty(); } } c# 头发染色,面部磨皮变白 C/S与B/S模式结合 这种属性怎么写? 如何建立一个FORM使其大小能大于屏幕分辨率大小? c#刚学,请教高手 TabControl控件的分页可以消隐吗? 如何在dataGridView中添加ComBobox到指定行中 关于列表控件的selectIndexChanged事件的问题 关于反射的效率问题的讨论 WebRequest WReq=WebRequest.Create()中的字符串该怎么使用? 【WPF】简单问题,大家帮我看一下。为什么Bubbling时为什么捕捉不到? C# winform 打开DBF文件出错(XP环境下)
MessageBox.Show(s);
跨平台获取当前工作目录
html:<asp:FileUpload runat="server" id="CardUpload"></asp:FileUpload>
<input id="Import" onclick="GetUrl();" type="button" value="导入" class="button" runat="server" />
<asp:HiddenField ID="hidPath" runat="server" />
js代码:
function GetUrl() {
//判断浏览器类型
var isIE = (document.all) ? true : false;
var isIE7 = isIE && (navigator.userAgent.indexOf('MSIE 7.0') != -1);
var isIE8 = isIE && (navigator.userAgent.indexOf('MSIE 8.0') != -1);
var file = document.getElementById("CardUpload");
if (isIE7 || isIE8) {
file.select();
document.getElementById("hidPath").value = document.selection.createRange().text;
document.selection.empty();
}
}