代码之家  ›  专栏  ›  技术社区  ›  nportelli

如何在Compact框架中获取当前目录?

  •  13
  • nportelli  · 技术社区  · 16 年前

    如何获取应用程序运行的当前目录?

    3 回复  |  直到 11 年前
        1
  •  17
  •   Kieron    16 年前

    你可以试试这个:

    using System.IO;
    using System.Reflection;
    
    namespace Utilities
    {
        static public class DirectoryHelper
        {
            static public string GetCurrentDirectory ()
            {
                return Path.GetDirectoryName (Assembly.GetExecutingAssembly ().GetName ().CodeBase);
            }
        }
    }
    
        2
  •  6
  •   cHao    16 年前

    试试这个:

    Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
    
        3
  •  -1
  •   user2956093    11 年前

    公共共享Sub-WriteDBStatus(ByVal StrString作为字符串)

        Try
    
            Dim FILE_NAME As String = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase) + "\DBStatus"
    
            Dim sr As IO.StreamWriter = Nothing
            If Not IO.File.Exists(FILE_NAME) Then
                sr = IO.File.CreateText(FILE_NAME)
                sr.WriteLine(strString)
            End If
            sr.Close()
        Catch ex As Exception
    
        End Try
    
    
    End Sub