2008-11-12 81 views

回答

17

你可以試試這個:

using System.IO; 
using System.Reflection; 

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

試試這個:

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

公共共享小組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