桌面文件的路径怎么获取?
我在桌面的txt文件的详细信息里获取的文件路径,但是进行读写操作没有提示错误可文件里是什么都没有。在D盘又进行相同的操作却可以把字符写进去。不知桌面文件的操作哪里错了。C:\Users\syx\桌面\wenjian.txt
C:\\Users\syx\桌面\wenjian.txt
C:\\wenjian.txt
这些都不可以
D盘的文件路径 D:\wenjian2.txt
求指教
2015-07-30 10:06
2015-07-30 10:26
2015-07-30 10:37
程序代码:#include <stdio.h>
#include <windows.h>
#include <shlobj.h>
#include <locale.h>
int main()
{
TCHAR szPath[MAX_PATH]={0};
setlocale(LC_ALL,"chs");
for(int i=0;i<26;i++)
{
SHGetSpecialFolderPath( NULL, szPath,i, FALSE );
wprintf(L"%ls\n",szPath);
}
return 0;
}
/*
C:\Documents and Settings\hh\桌面
C:\Documents and Settings\hh\「开始」菜单\程序
D:\my documents
C:\Documents and Settings\hh\Favorites
C:\Documents and Settings\hh\「开始」菜单\程序\启动
C:\Documents and Settings\hh\Recent
C:\Documents and Settings\hh\SendTo
C:\Documents and Settings\hh\「开始」菜单
D:\my documents\My Music
C:\Documents and Settings\hh\桌面
C:\Documents and Settings\hh\NetHood
C:\WINDOWS\Fonts
C:\Documents and Settings\hh\Templates
C:\Documents and Settings\All Users\「开始」菜单
C:\Documents and Settings\All Users\「开始」菜单\程序
C:\Documents and Settings\All Users\「开始」菜单\程序\启动
C:\Documents and Settings\All Users\桌面
*/

2015-07-30 11:29
2015-07-30 12:45
程序代码:#include <stdio.h>
#include <windows.h>
#include <shlobj.h>
#include <locale.h>
int main()
{
TCHAR szPath[MAX_PATH]={0};
setlocale(LC_ALL,"chs");
SHGetSpecialFolderPath(NULL, szPath,0, FALSE);
lstrcat(szPath,L"\\abc.txt");
FILE* fp;
fp=_wfopen(szPath,L"w+");
fputs("this is a test text.",fp);
fputs("\n这是一段测试文本。",fp);
fclose(fp);
return 0;
}

2015-07-30 13:53
2015-07-30 17:08
2015-07-30 23:04
2015-07-30 23:04
2015-07-30 23:04