Exemple #1
0
        /// <summary>
        /// 自分自身のアプリケーションディレクトリを取得する
        /// </summary>
        /// <returns></returns>
        public static string GetApplicationDirectory()
        {
            string path = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;

            //URIを通常のパス形式に変換する
            Uri u = new Uri(path);

            path = u.LocalPath + Uri.UnescapeDataString(u.Fragment);
            return(File.GetDirectoryName(path));
        }
Exemple #2
0
        /// <summary>
        /// 拡張子を取り除いたパスを取得する
        /// </summary>
        /// <param name="targetPath">対象パス</param>
        /// <returns>対象パスから拡張子を取り除いたパス</returns>
        public static string GetWithoutExtension(string targetPath)
        {
            if (String.IsNullOrEmpty(targetPath))
            {
                //null or Empty
                return("");
            }

            //IO.Path.GetFileNameWithoutExtensionはファイル名しか返さないので、パスを付ける
            return(File.GetDirectoryName(targetPath) + System.IO.Path.GetFileNameWithoutExtension(targetPath));
        }