How do you get the current directory in compact framework?

陌路散爱 提交于 2019-12-09 02:29:43

问题


How do you get the current directory where your app is running?


回答1:


You could try this:

using System.IO;
using System.Reflection;

namespace Utilities
{
    static public class DirectoryHelper
    {
        static public string GetCurrentDirectory ()
        {
            return Path.GetDirectoryName (Assembly.GetExecutingAssembly ().GetName ().CodeBase);
        }
    }
}



回答2:


Try this:

Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);



回答3:


Public Shared Sub WriteDBStatus(ByVal strString As String)

    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


来源:https://stackoverflow.com/questions/284049/how-do-you-get-the-current-directory-in-compact-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!