如果您的Windows Mobile版本下7(窗口响度单位)工作检查: C#代码:
public static string GetFolderPath(SpecialFolder folder)
{
//buffer to fill with path
StringBuilder path = new StringBuilder(MaxPath);
//pass stringbuilder and folder identifier to api function
if(!Convert.ToBoolean(SHGetSpecialFolderPath(IntPtr.Zero,
path, (int)folder, 0)))
{
throw new Exception("Cannot get folder path!");
}
return path.ToString();
}
[DllImport("coredll", EntryPoint="SHGetSpecialFolderPath",
SetLastError=false)]
internal static extern int SHGetSpecialFolderPath(IntPtr hwndOwner,
StringBuilder lpszPath, int nFolder, int fCreate);
VB.net代码:
Public Shared Function GetFolderPath(folder As SpecialFolder) As String
'buffer to fill with path
Dim path As New StringBuilder(MaxPath)
'pass stringbuilder and folder identifier to api function
If Not Convert.ToBoolean(SHGetSpecialFolderPath(IntPtr.Zero, path, CInt(folder), 0)) Then
Throw New Exception("Cannot get folder path!")
End If
Return path.ToString()
End Function
<DllImport("coredll", EntryPoint := "SHGetSpecialFolderPath", SetLastError := False)> _
Friend Shared Function SHGetSpecialFolderPath(hwndOwner As IntPtr, lpszPath As StringBuilder, nFolder As Integer, fCreate As Integer) As Integer
End Function
你得Import System.Environment
看到特殊文件夹和 Import System.Runtime.InteropServices
以查看DllImport
有关详细信息:http://msdn.microsoft.com/en-us/library/aa446567.aspx#spfiles_topic_03
请,如果它的工作记住我的答案右
假设你对你的问题的标题是正确的,在移动环境中'Progam Files'不存在,并且你的数据库文件应该在你的应用根路径中。 – balexandre 2012-02-20 08:20:11