zoukankan      html  css  js  c++  java
  • 获取文件路径

        /// <summary>         /// 从程序中读取当前文件的路径         /// </summary>         /// <returns></returns>         private string GetCurrentPathByCSharp()         {

                StringBuilder _StringBuilder = new StringBuilder();             string str = "";

                _StringBuilder.AppendLine("1、获取当前进程的完整路径,包含文件名(进程名)。");             _StringBuilder.AppendLine("this.GetType().Assembly.Location");             _StringBuilder.AppendLine(this.GetType().Assembly.Location);             _StringBuilder.AppendLine("-------------------------------------------------");

                _StringBuilder.AppendLine("2、获取和设置当前目录(即该进程从中启动的目录)的完全限定路径。");             _StringBuilder.AppendLine("System.Environment.CurrentDirectory");             _StringBuilder.AppendLine(System.Environment.CurrentDirectory);             _StringBuilder.AppendLine("-------------------------------------------------");

                _StringBuilder.AppendLine("3、获得应用程序的当前工作目录,这不一定是从程序中启动的目录。");             _StringBuilder.AppendLine("System.IO.Directory.GetCurrentDirectory()");             _StringBuilder.AppendLine(System.IO.Directory.GetCurrentDirectory());             _StringBuilder.AppendLine("-------------------------------------------------");

                _StringBuilder.AppendLine("4、获取当前 Thread 的当前应用程序域的基目录,它由程序集冲突解决程序用来探测程序集。");             _StringBuilder.AppendLine("System.AppDomain.CurrentDomain.BaseDirectory");             _StringBuilder.AppendLine(System.AppDomain.CurrentDomain.BaseDirectory);             _StringBuilder.AppendLine("-------------------------------------------------");

                _StringBuilder.AppendLine("5、获取和设置包含该应用程序的目录的名称。");             _StringBuilder.AppendLine("System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase");             _StringBuilder.AppendLine(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase);             _StringBuilder.AppendLine("-------------------------------------------------");

                _StringBuilder.AppendLine("6、获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称。");             _StringBuilder.AppendLine("System.Windows.Forms.Application.StartupPath");             _StringBuilder.AppendLine(System.Windows.Forms.Application.StartupPath);             _StringBuilder.AppendLine("-------------------------------------------------");

                _StringBuilder.AppendLine("7、获取启动了应用程序的可执行文件的路径,包括可执行文件的名称。");             _StringBuilder.AppendLine("System.Windows.Forms.Application.ExecutablePath");             _StringBuilder.AppendLine(System.Windows.Forms.Application.ExecutablePath);             _StringBuilder.AppendLine("-------------------------------------------------");

                _StringBuilder.AppendLine("8、获取新的 Process 组件并将其与当前活动的进程关联的主模块的完整路径,包含文件名(进程名)。");             _StringBuilder.AppendLine("System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName");             _StringBuilder.AppendLine(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);             _StringBuilder.AppendLine("-------------------------------------------------");

                //this.Context.Parameters["targetdir"] = @"d:\cc5";             //string path = this.Context.Parameters["targetdir"];//安装目录

                string localPath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, @"Temp\EditionDown.zip");                          localPath = _StringBuilder.ToString();

                System.IO.File.WriteAllText(@"d:\1.txt",localPath);             throw new Exception(localPath);                         return localPath;         }

  • 相关阅读:
    taotao-manager/taotao-manager-interface/pom.xml
    taotao-manager/taotao-manager-pojo/pom.xml
    taotao-manager/pom.xml
    taotao-manager/taotao-manager-dao/pom.xml
    taotao-common/pom.xml
    taotao-parent/pom.xml(父工程的pom.xml文件配置)
    idea社区版使用maven运行web项目
    IntelliJ IDEA Community社区版集成Tomcat教程
    linux中没有tree命令,command not found,解决办法
    数据导入导出
  • 原文地址:https://www.cnblogs.com/mingyongcheng/p/2985113.html
Copyright © 2011-2022 走看看