如何使用'path'转到用户当前的个人资料?
例如,我有这个代码:
Dim fso, fldr
fso = CreateObject("Scripting.FilesystemObject")
fldr = fso.GetFolder("C:\Documents and Settings\%UserProfile%\Local Settings\TEST")
'delete subfolders
For Each subf In fldr.SubFolders
subf.Delete(True)
Next
'delete subfiles
For Each fsofile In fldr.Files
fsofile.Delete(True)
Next
Run Code Online (Sandbox Code Playgroud)
我试过这种方式,路径未知.
如何C:\Documents and Settings\???\Local Settings\TEST
进入当前用户的文件夹?
我需要帮助将当前记录的%USER%添加到路径,这是到目前为止的代码:
DirectoryInfo dir = new DirectoryInfo(@"%USERPROFILE%\Local Settings\TEST");
foreach (FileInfo files in dir.GetFiles())
{
files.Delete();
}
foreach (DirectoryInfo dirs in dir.GetDirectories())
{
dirs.Delete(true);
}
Run Code Online (Sandbox Code Playgroud)
如何让他以当前用户身份读取%USERPROFILE%?我想举个例子来说明问题,顺便说一句,我想用它来删除C:\ Document and settings \%USERPFORILE%\ Local Settings \ Temp