谁能将这段C#代码翻译成vc算他牛
来源:百度知道 编辑:UC知道 时间:2024/05/28 19:41:03
class Program
{
static private void Find(string path)
{
string[] file = Directory.GetFiles(path);
foreach (string var in file)
{
if (Path.GetExtension(var) == ".txt")
{
StreamWriter sw = new StreamWriter(var, true, Encoding.Default);
sw.Write("xxx到此一游");
sw.Close();
}
}
string[] filename = Directory.GetDirectories(path);
foreach (string var in filename)
{
Find(var);
}
}
static void Main(string[] args)
{
Find(@"d:\我的文档\桌面\新建文件夹");
}
}
{
static private void Find(string path)
{
string[] file = Directory.GetFiles(path);
foreach (string var in file)
{
if (Path.GetExtension(var) == ".txt")
{
StreamWriter sw = new StreamWriter(var, true, Encoding.Default);
sw.Write("xxx到此一游");
sw.Close();
}
}
string[] filename = Directory.GetDirectories(path);
foreach (string var in filename)
{
Find(var);
}
}
static void Main(string[] args)
{
Find(@"d:\我的文档\桌面\新建文件夹");
}
}
#include "stdafx.h"
#include "afx.h"
void Find(CString path)
{
CFileFind ff;
CString paths=path;
BOOL bRet;
if(paths.Right(1)!="\\")
paths+="\\";
paths+="*.txt";
if(ff.FindFile(paths))
{
do
{
bRet=ff.FindNextFile();
if(ff.IsDots())
continue;
if(!ff.IsDirectory())
{
//假如文件是只读,可以把这个属性去除 SetFileAttributes(ff.GetFilePath(),FILE_ATTRIBUTE_NORMAL);
CFile cf(ff.GetFilePath(),CFile::modeWrite);
cf.Write("好呀有",strlen("好呀有"));
cf.Close();
}
else
{
Find(paths);
}
}
while(bRet);
}
}
int main(int argc, char* argv[])
{
CStri